Skip to content

Commit

Permalink
refactor: use address from npm packages
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 21, 2023
1 parent 143d30f commit f2455ac
Show file tree
Hide file tree
Showing 31 changed files with 256 additions and 171 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"codegen": "yarn workspaces foreach run codegen",
"create:local": "yarn workspaces foreach run create:local",
"build:local": "yarn workspaces foreach run build:local",
"build:testnet": "yarn workspaces foreach run build:testnet",
"build:mainnet": "yarn workspaces foreach run build:mainnet",
"build:chapel": "yarn workspaces foreach run build:chapel",
"build:bsc": "yarn workspaces foreach run build:bsc",
"deploy:local": "yarn workspaces foreach run deploy:local",
"deploy:testnet": "yarn workspaces foreach run deploy:testnet",
"deploy:mainnet": "yarn workspaces foreach run deploy:mainnet",
"deploy:chapel": "yarn workspaces foreach run deploy:chapel",
"deploy:bsc": "yarn workspaces foreach run deploy:bsc",
"prepare:local": "yarn workspaces foreach run prepare:local",
"prepare:testnet": "yarn workspaces foreach run prepare:testnet",
"prepare:mainnet": "yarn workspaces foreach run prepare:mainnet",
"prepare:chapel": "yarn workspaces foreach run prepare:chapel",
"prepare:bsc": "yarn workspaces foreach run prepare:bsc",
"remove:local": "yarn workspaces foreach run remove:local",
"generate-subgraph-types": "yarn workspaces foreach run generate-subgraph-types",
"lint": "eslint '**/*.{ts,tsx}'",
Expand All @@ -46,10 +46,11 @@
"@typechain/hardhat": "^6.1.2",
"@types/mocha": "^9.1.1",
"@types/mustache": "^4.2.1",
"@types/node": "^20.5.9",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@venusprotocol/governance-contracts": "^1.0.0",
"@venusprotocol/isolated-pools": "1.0.0",
"@venusprotocol/isolated-pools": "1.3.0",
"@venusprotocol/oracle": "^1.4.1",
"@venusprotocol/venus-protocol": "^3.0.0-dev.7",
"assemblyscript": "0.19.23",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const deploy = async ({
exec(`yarn workspace ${packageName} run build:local`, root);
exec(`yarn workspace ${packageName} run create:local`, root);
exec(
`npx graph deploy ${subgraphAccount}/${subgraphName} --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`,
`npx graph deploy ${subgraphAccount}/${subgraphName} --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`,
root,
);
await waitForSubgraphToBeSynced(syncDelay);
Expand Down
6 changes: 0 additions & 6 deletions subgraphs/isolated-pools/config/bsc.json

This file was deleted.

6 changes: 0 additions & 6 deletions subgraphs/isolated-pools/config/chapel.json

This file was deleted.

55 changes: 55 additions & 0 deletions subgraphs/isolated-pools/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import mainnetDeployments from '@venusprotocol/isolated-pools/deployments/bscmainnet.json';
import sepoliaDeployments from '@venusprotocol/isolated-pools/deployments/bsctestnet.json';
import chapelDeployments from '@venusprotocol/isolated-pools/deployments/bsctestnet.json';
import fs from 'fs';
import Mustache from 'mustache';

export const getNetwork = () => {
const supportedNetworks = ['sepolia', 'chapel', 'bsc', 'local'] as const;
const network = process.env.NETWORK;
// @ts-expect-error network env var is unknown here
if (!supportedNetworks.includes(network)) {
throw new Error(`NETWORK env var must be set to one of ${supportedNetworks}`);
}
return network as typeof supportedNetworks[number];
};

const main = () => {
const network = getNetwork();
const config = {
local: {
network: 'hardhat',
poolRegistryAddress: '0x95401dc811bb5740090279Ba06cfA8fcF6113778',
poolLensAddress: '0x809d550fca64d94Bd9F66E60752A544199cfAC3D',
startBlock: 0,
},
sepolia: {
network: 'sepolia',
poolRegistryAddress: sepoliaDeployments.contracts.PoolRegistry.address,
poolLensAddress: sepoliaDeployments.contracts.PoolLens.address,
startBlock: '3930059',
},
chapel: {
network: 'chapel',
poolRegistryAddress: chapelDeployments.contracts.PoolRegistry.address,
poolLensAddress: chapelDeployments.contracts.PoolLens.address,
startBlock: '30870000',
},
bsc: {
network: 'bsc',
poolRegistryAddress: mainnetDeployments.contracts.PoolRegistry.address,
poolLensAddress: mainnetDeployments.contracts.PoolLens.address,
startBlock: '29300000',
},
};

const yamlTemplate = fs.readFileSync('template.yaml', 'utf8');
const yamlOutput = Mustache.render(yamlTemplate, config[network]);
fs.writeFileSync('subgraph.yaml', yamlOutput);

const configTemplate = fs.readFileSync('src/constants/config-template', 'utf8');
const tsOutput = Mustache.render(configTemplate, config[network]);
fs.writeFileSync('src/constants/config.ts', tsOutput);
};

main();
6 changes: 0 additions & 6 deletions subgraphs/isolated-pools/config/local.json

This file was deleted.

6 changes: 0 additions & 6 deletions subgraphs/isolated-pools/config/sepolia.json

This file was deleted.

18 changes: 9 additions & 9 deletions subgraphs/isolated-pools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"create:docker": "npx graph create venusprotocol/venus-isolated-pools --node http://graph-node:8020/",
"build:docker": "npx graph build --ipfs http://ipfs:5001",
"build:bsc": "npx graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:local": "LOCAL=true npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "npx mustache config/local.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs http://ipfs:5001 --node http://graph-node:8020/",
"deploy:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools-chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx graph deploy venusprotocol/venus-isolated-pools --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:sepolia": "yarn prepare:sepolia && npx graph deploy --studio venus-isolated-pools-sepolia",
"prepare:local": "npx mustache config/local.json template.yaml > subgraph.yaml && npx mustache config/local.json src/constants/config-template > src/constants/config.ts",
"prepare:chapel": "npx mustache config/chapel.json template.yaml > subgraph.yaml && npx mustache config/chapel.json src/constants/config-template > src/constants/config.ts",
"prepare:bsc": "npx mustache config/bsc.json template.yaml > subgraph.yaml && npx mustache config/bsc.json src/constants/config-template > src/constants/config.ts",
"prepare:sepolia": "npx mustache config/sepolia.json template.yaml > subgraph.yaml && npx mustache config/sepolia.json src/constants/config-template > src/constants/config.ts",
"deploy:local": "LOCAL=true prepare:local && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/",
"deploy:docker": "prepare:local && npx graph deploy venusprotocol/venus-isolated-pools --ipfs http://ipfs:5001 --node http://graph-node:8020/",
"deploy:chapel": "prepare:chapel && npx graph deploy venusprotocol/venus-isolated-pools-chapel --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "prepare:bsc && npx graph deploy venusprotocol/venus-isolated-pools --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:sepolia": "prepare:sepolia && npx graph deploy --studio venus-isolated-pools-sepolia",
"prepare:local": "NETWORK=local npx ts-node config/index.ts",
"prepare:chapel": "NETWORK=chapel npx ts-node config/index.ts",
"prepare:bsc": "NETWORK=chapel npx ts-node config/index.ts",
"prepare:sepolia": "NETWORK=sepolia npx ts-node config/index.ts",
"remove:local": "npx graph remove --node http://127.0.0.1:8020/ venusprotocol/venus-isolated-pools",
"remove:docker": "npx graph remove --node http://graph-node:8020/ venusprotocol/venus-isolated-pools",
"generate-subgraph-types": "rm -rf /subgraph-client/.graphclient && yarn graphclient build --dir ./subgraph-client",
Expand Down
4 changes: 2 additions & 2 deletions subgraphs/isolated-pools/tests/integration/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const deploy = async () => {
exec(`yarn workspace isolated-pools-subgraph run build:${env}`, root);
exec(`yarn workspace isolated-pools-subgraph run create:${env}`, root);
const deployCmd = process.env.LOCAL
? `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`
: `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --debug --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ${Date.now().toString()}`;
? `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020/ --version-label ${Date.now().toString()}`
: `npx graph deploy ${SUBGRAPH_ACCOUNT}/${SUBGRAPH_NAME} --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ${Date.now().toString()}`;
exec(deployCmd, root);
exec(`echo "" | yarn workspace isolated-pools-subgraph deploy:${env}`, __dirname);
await waitForSubgraphToBeSynced(SYNC_DELAY);
Expand Down
75 changes: 75 additions & 0 deletions subgraphs/venus-governance/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import fs from 'fs';
import Mustache from 'mustache';

export const getNetwork = () => {
const supportedNetworks = ['chapel', 'bsc', 'local'] as const;
const network = process.env.NETWORK;
// @ts-expect-error network env var is unknown here
if (!supportedNetworks.includes(network)) {
throw new Error(`NETWORK env var must be set to one of ${supportedNetworks}`);
}
return network as typeof supportedNetworks[number];
};

const main = () => {
const network = getNetwork();
const config = {
local: {
network: 'bsc',
accessControlManagerAddress: '0xc5a5C42992dECbae36851359345FE25997F5C42d',
accessControlManagerStartBlock: '0',
governorAlphaAddress: '0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1',
governorAlphaStartBlock: '0',
governorAlpha2Address: '0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE',
governorAlpha2StartBlock: '0',
governorBravoDelegateAddress: '0x5573422a1a59385c247ec3a66b93b7c08ec2f8f2',
governorBravoDelegateStartBlock: '16002994',
governorBravoDelegate2Address: '0x5573422a1a59385c247ec3a66b93b7c08ec2f8f2',
governorBravoDelegate2StartBlock: '16002994',
xvsTokenAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
xvsTokenStartBlock: '0',
xvsVaultAddress: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
xvsVaultStartBlock: '0',
},
chapel: {
network: 'chapel',
accessControlManagerAddress: '0x4a471468cdABA84CEA885aF72129F2e974C3649B',
accessControlManagerStartBlock: '24711629',
governorAlphaAddress: '0x7df10b2118eb04d9806b15198019f83741a9f8f4',
governorAlphaStartBlock: '8205736',
governorAlpha2Address: '0x7116894ed34FC4B27D5b84f46B70Af48397a6C24',
governorAlpha2StartBlock: '13584539',
governorBravoDelegateAddress: '0x5573422a1a59385c247ec3a66b93b7c08ec2f8f2',
governorBravoDelegateStartBlock: '16002994 ',
governorBravoDelegate2Address: '',
governorBravoDelegate2StartBlock: '',
xvsTokenAddress: '0xB9e0E753630434d7863528cc73CB7AC638a7c8ff',
xvsTokenStartBlock: '2802593',
xvsVaultAddress: '0xa4Fd54cACdA379FB7CaA783B83Cc846f8ac0Faa6',
xvsVaultStartBlock: '13937802',
},
bsc: {
network: 'bsc',
accessControlManagerAddress: '',
accessControlManagerStartBlock: '',
governorAlphaAddress: '0x406f48f47d25e9caa29f17e7cfbd1dc6878f078f',
governorAlphaStartBlock: '2474351',
governorAlpha2Address: '0x388313BfEFEE8ddfeAD55b585F62812293Cf3A60',
governorAlpha2StartBlock: '11934064',
governorBravoDelegateAddress: '0x2d56dC077072B53571b8252008C60e945108c75a',
governorBravoDelegateStartBlock: '13729317',
governorBravoDelegate2Address: '',
governorBravoDelegate2StartBlock: '',
xvsTokenAddress: '0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63',
xvsTokenStartBlock: '858561',
xvsVaultAddress: '0x6eF49b4e0772Fe78128F981d42D54172b55eCF9F',
xvsVaultStartBlock: '13018718',
},
};

const yamlTemplate = fs.readFileSync('template.yaml', 'utf8');
const yamlOutput = Mustache.render(yamlTemplate, config[network]);
fs.writeFileSync('subgraph.yaml', yamlOutput);
};

main();
17 changes: 0 additions & 17 deletions subgraphs/venus-governance/config/local.json

This file was deleted.

17 changes: 0 additions & 17 deletions subgraphs/venus-governance/config/mainnet.json

This file was deleted.

17 changes: 0 additions & 17 deletions subgraphs/venus-governance/config/testnet.json

This file was deleted.

16 changes: 8 additions & 8 deletions subgraphs/venus-governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"codegen": "graph codegen",
"create:local": "graph create venusprotocol/venus-governance --node http://127.0.0.1:8020",
"build:local": "graph build --ipfs http://localhost:5001",
"build:mainnet": "graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:integration": "graph deploy venusprotocol/venus-governance --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020/",
"deploy:local": "npx mustache config/local.json template.yaml > subgraph.yaml && yarn deploy:integration",
"deploy:testnet": "npx mustache config/testnet.json template.yaml > subgraph.yaml && graph deploy venusprotocol/venus-governance-chapel --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:mainnet": "npx mustache config/mainnet.json template.yaml > subgraph.yaml && graph deploy venusprotocol/venus-governance --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prepare:local": "npx mustache config/local.json template.yaml > subgraph.yaml",
"prepare:testnet": "npx mustache config/testnet.json template.yaml > subgraph.yaml",
"prepare:mainnet": "npx mustache config/mainnet.json template.yaml > subgraph.yaml",
"build:bsc": "graph build --ipfs https://api.thegraph.com/ipfs/ ",
"deploy:integration": "npx graph deploy venusprotocol/venus-governance --ipfs http://localhost:5001 --node http://127.0.0.1:8020/",
"deploy:local": "prepare:local && yarn deploy:integration",
"deploy:chapel": "prepare:chapel && npx graph deploy venusprotocol/venus-governance-chapel --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:bsc": "prepare:bsc && npx graph deploy venusprotocol/venus-governance --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"prepare:local": "NETWORK=local npx ts-node config/index.ts",
"prepare:chapel": "NETWORK=chapel npx ts-node config/index.ts",
"prepare:bsc": "NETWORK=bsc npx ts-node config/index.ts",
"remove:local": "graph remove --node http://localhost:8020/ venusprotocol/venus-governance",
"generate-subgraph-types": "yarn graphclient build --dir ./subgraph-client",
"test": "graph test",
Expand Down
46 changes: 46 additions & 0 deletions subgraphs/venus/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env ts-node
import bscMainnetCoreDeployments from '@venusprotocol/venus-protocol/networks/mainnet.json';
import bscTestnetCoreDeployments from '@venusprotocol/venus-protocol/networks/testnet.json';
import fs from 'fs';
import Mustache from 'mustache';

export const getNetwork = () => {
const supportedNetworks = ['chapel', 'bsc', 'local'] as const;
const network = process.env.NETWORK;
// @ts-expect-error network env var is unknown here
if (!supportedNetworks.includes(network)) {
throw new Error(`NETWORK env var must be set to one of ${supportedNetworks}`);
}
return network as typeof supportedNetworks[number];
};

const main = () => {
const network = getNetwork();
const config = {
local: {
network: 'hardhat',
comptrollerAddress: '0x94d1820b2D1c7c7452A163983Dc888CEC546b77D',
startBlock: '0',
},
chapel: {
network: 'chapel',
comptrollerAddress: bscTestnetCoreDeployments.Contracts.Comptroller,
startBlock: '2470000',
},
bsc: {
network: 'bsc',
comptrollerAddress: bscMainnetCoreDeployments.Contracts.Comptroller,
startBlock: '2470000',
},
};

const yamlTemplate = fs.readFileSync('template.yaml', 'utf8');
const yamlOutput = Mustache.render(yamlTemplate, config[network]);
fs.writeFileSync('subgraph.yaml', yamlOutput);

const configTemplate = fs.readFileSync('src/constants/config-template', 'utf8');
const tsOutput = Mustache.render(configTemplate, config[network]);
fs.writeFileSync('src/constants/config.ts', tsOutput);
};

main();
5 changes: 0 additions & 5 deletions subgraphs/venus/config/local.json

This file was deleted.

5 changes: 0 additions & 5 deletions subgraphs/venus/config/mainnet.json

This file was deleted.

5 changes: 0 additions & 5 deletions subgraphs/venus/config/testnet.json

This file was deleted.

Loading

0 comments on commit f2455ac

Please sign in to comment.