forked from vanshwassan/comet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateFrontendConfiguration.js
55 lines (51 loc) · 1.67 KB
/
generateFrontendConfiguration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const fs = require("fs");
const config = JSON.parse(
fs.readFileSync("api3-adaptors/config.json", "utf8")
);
const aliases = JSON.parse(
fs.readFileSync(`deployments/${config.network.name}/usdc/aliases.json`, "utf8")
);
const configuration = JSON.parse(
fs.readFileSync(`deployments/${config.network.name}/usdc/configuration.json`, "utf8")
);
let frontendConfig = {
currentMarket: "compound",
compound: {
config: {
baseToken: configuration.baseTokenAddress,
rewardToken: configuration?.assets?.[configuration.rewardToken]?.address,
network: {
chainId: config.network.chainId,
name: config.network.name,
rpc: config.network.rpc,
nativeCurrency: config.network.nativeCurrency,
explorerLink: config.network.explorerLink,
},
},
"deployed-contracts": {
...aliases,
USDC: configuration.baseTokenAddress,
priceFeeds: {},
},
},
};
for (let assetSymbol in configuration.assets) {
// Add the asset to the frontendConfig
// frontendConfig.config.assets.push({
// symbol: assetSymbol,
// address: configuration.assets[assetSymbol].address,
// priceFeed: configuration.assets[assetSymbol].priceFeed,
// decimals: configuration.assets[assetSymbol].decimals,
// });
frontendConfig.compound["deployed-contracts"].priceFeeds[assetSymbol] =
configuration.assets[assetSymbol].priceFeed;
}
// add base token price feed
frontendConfig.compound["deployed-contracts"].priceFeeds[
configuration.baseToken
] = configuration.baseTokenPriceFeed;
// Write the frontendConfig to a new JSON file
fs.writeFileSync(
"api3-aave-ui/deployment-configs.json",
JSON.stringify(frontendConfig, null, 2)
);