forked from DefiLlama/yield-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateConfig.js
40 lines (33 loc) · 1.17 KB
/
createConfig.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
const fs = require('fs');
const superagent = require('superagent');
const { confirm } = require('./confirm');
const { connect } = require('../src/utils/dbConnection');
const { buildInsertConfigQuery } = require('../src/queries/config');
(async () => {
await confirm(
`Confirm with 'yes' if you want to start the ${process.argv[1]
.split('/')
.slice(-1)} script: `
);
const uuids = JSON.parse(fs.readFileSync('./created_uuids.json'));
const urls = (await superagent.get('https://yields.llama.fi/url')).body;
let data = JSON.parse(fs.readFileSync('./yield_snapshot_last.json'));
data = data.map((p) => ({
config_id: uuids[p.pool],
pool: p.pool,
project: p.project,
chain: p.chain,
symbol: p.symbol,
poolMeta: p.poolMeta,
underlyingTokens:
p?.underlyingTokens?.length > 0 ? p?.underlyingTokens : null,
rewardTokens: p?.rewardTokens?.length > 0 ? p?.rewardTokens : null,
url: urls[p.project],
}));
// build multi row insert query
const insertConfigQ = buildInsertConfigQuery(data);
const conn = await connect();
const response = await conn.result(insertConfigQ);
console.log(response);
process.exit(0);
})();