-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (25 loc) · 865 Bytes
/
index.js
File metadata and controls
34 lines (25 loc) · 865 Bytes
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
const raw = require('./config.json');
const loadAbi = (name) => require(`./out/${name}.sol/${name}.abi.json`);
const abis = () => ({
wm: loadAbi('WM'),
repermit: loadAbi('RePermit'),
reactor: loadAbi('OrderReactor'),
executor: loadAbi('Executor'),
refinery: loadAbi('Refinery'),
settler: loadAbi('Settler'),
adapter: loadAbi('DefaultDexAdapter'),
});
function config(chainId, dexName) {
if (!chainId) return;
const { dex: _globalDex, ...baseDefaults } = raw['*'] ?? {};
const chainConfig = raw[chainId];
if (!chainConfig) return;
const { dex, ...chainDefaults } = chainConfig;
if (!dexName?.trim()) {
return { ...baseDefaults, ...chainDefaults };
}
const dexOverrides = dex?.[dexName];
if (!dexOverrides) return;
return { ...baseDefaults, ...chainDefaults, ...dexOverrides };
}
module.exports = { config, abis, raw };