Skip to content

Commit bf5e536

Browse files
authored
Merge pull request #153 from Gearbox-protocol/pools-config
feat: generate pool config
2 parents d33d3af + e2cb992 commit bf5e536

File tree

8 files changed

+329
-47
lines changed

8 files changed

+329
-47
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"license": "MIT",
1111
"scripts": {
1212
"compile": "tsc",
13-
"dev": "tsc && yarn generate-strategies:ts",
13+
"dev": "tsc && yarn generate-configs:ts",
1414
"clean": "rm -rf ./lib",
1515
"copy-files": "mkdir -p ./src/assets && cp -R ./src/assets ./lib",
16-
"build": "yarn compile && yarn generate-strategies:ts && yarn copy-files",
17-
"generate-strategies:ts": "npx ts-node scripts/generate-strategies.ts",
16+
"build": "yarn compile && yarn generate-configs:ts && yarn copy-files",
17+
"generate-configs:ts": "npx ts-node scripts/generate-configs.ts",
1818
"prepare": "husky install",
1919
"prettier": "prettier --write .",
2020
"prettier:ci": "npx prettier --check .",

scripts/generate-configs.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import * as fs from "fs";
2+
import * as path from "path";
3+
4+
import { POOLS_LIST } from "../src/pools";
5+
import { STRATEGIES_LIST } from "../src/strategies";
6+
7+
const CONFIG = [
8+
{
9+
outputDir: ["..", "public", "strategies"],
10+
outputFile: "strategies.json",
11+
source: STRATEGIES_LIST,
12+
},
13+
{
14+
outputDir: ["..", "public", "client-v3", "configs", "strategies"],
15+
outputFile: "strategies.json",
16+
source: STRATEGIES_LIST,
17+
},
18+
{
19+
outputDir: ["..", "public", "client-v3", "configs", "pools"],
20+
outputFile: "pools.json",
21+
source: POOLS_LIST,
22+
},
23+
];
24+
25+
function generateStrategiesJson(): void {
26+
for (let { outputDir: dir, outputFile: file, source } of CONFIG) {
27+
try {
28+
// Define the output directory and file path
29+
const outputDir = path.join(__dirname, ...dir);
30+
const outputFile = path.join(outputDir, file);
31+
32+
// Create the directory if it doesn't exist
33+
if (!fs.existsSync(outputDir)) {
34+
fs.mkdirSync(outputDir, { recursive: true });
35+
console.log(`Created directory: ${outputDir}`);
36+
}
37+
38+
// Remove existing file if it exists
39+
if (fs.existsSync(outputFile)) {
40+
fs.unlinkSync(outputFile);
41+
console.log(`Removed existing file: ${outputFile}`);
42+
}
43+
44+
// Transform source to JSON string
45+
const jsonString = JSON.stringify(source, null, 2);
46+
47+
// Write the JSON file
48+
fs.writeFileSync(outputFile, jsonString, "utf8");
49+
50+
console.log(
51+
`Successfully generated ${file} with ${source.length} entries`,
52+
);
53+
console.log(`File saved to: ${outputFile}`);
54+
} catch (error) {
55+
console.error(`Error generating ${file}:`, error);
56+
process.exit(1);
57+
}
58+
}
59+
}
60+
61+
// Run the script
62+
generateStrategiesJson();

scripts/generate-strategies.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/core/pools.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export type TokenTypePool = "eth" | "stable" | "btc" | "wbnb" | "s" | "hemiBTC";
2+
3+
export interface PoolConfigPayload {
4+
// is used to recognize pool in the list; maybe show this name instead of version + underlying symbol?
5+
name: string;
6+
// pool address
7+
address: Address;
8+
// chain id and network type as in sdk. wrong entries are being omitted
9+
chainId: number;
10+
network: string;
11+
// is used to recognize pool in the list; maybe show this name instead name from sdk?
12+
curator: string;
13+
poolType: [TokenTypePool];
14+
}
15+
16+
type Address = `0x${string}`;

src/core/strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type TokenTypeStrategy =
77
| "wxtz"
88
| "bfBTC";
99

10-
export interface StrategyPayload {
10+
export interface StrategyConfigPayload {
1111
name: string;
1212
id: string;
1313
tokenOut: string;

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./core/pools";
12
export * from "./core/strategy";
23
export * from "./icons/agents";
34
export * from "./icons/arrowUnderlying";

src/pools/index.ts

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
import type { PoolConfigPayload } from "../core/pools";
2+
3+
export const POOLS_LIST: Array<PoolConfigPayload> = [
4+
{
5+
name: "Trade WETH v3",
6+
address: "0xda0002859b2d05f66a753d8241fcde8623f26f4f",
7+
chainId: 1,
8+
network: "Mainnet",
9+
curator: "Chaos Labs",
10+
poolType: ["eth"],
11+
},
12+
{
13+
name: "Gearbox WETH v3",
14+
address: "0xf00b548f1b69cb5ee559d891e03a196fb5101d4a",
15+
chainId: 1,
16+
network: "Mainnet",
17+
curator: "cp0x",
18+
poolType: ["eth"],
19+
},
20+
{
21+
name: "wstETH v3",
22+
address: "0xff94993fa7ea27efc943645f95adb36c1b81244b",
23+
chainId: 1,
24+
network: "Mainnet",
25+
curator: "Chaos Labs",
26+
poolType: ["eth"],
27+
},
28+
{
29+
name: "wstETH v3",
30+
address: "0x72ccb97cbdc40f8fb7ffa42ed93ae74923547200",
31+
chainId: 1,
32+
network: "Mainnet",
33+
curator: "cp0x",
34+
poolType: ["eth"],
35+
},
36+
{
37+
name: "Trade USDC v3",
38+
address: "0xda00000035fef4082f78def6a8903bee419fbf8e",
39+
chainId: 1,
40+
network: "Mainnet",
41+
curator: "Chaos Labs",
42+
poolType: ["stable"],
43+
},
44+
{
45+
name: "USDC",
46+
address: "0xc155444481854c60e7a29f4150373f479988f32d",
47+
chainId: 1,
48+
network: "Mainnet",
49+
curator: "Invariant Group",
50+
poolType: ["stable"],
51+
},
52+
{
53+
name: "Universal USDT v3",
54+
address: "0x05a811275fe9b4de503b3311f51edf6a856d936e",
55+
chainId: 1,
56+
network: "Mainnet",
57+
curator: "Chaos Labs",
58+
poolType: ["stable"],
59+
},
60+
{
61+
name: "K3 USDT v3 stable",
62+
address: "0xf5503d3d4bd254c2c17690eed523bcb2935db6de",
63+
chainId: 1,
64+
network: "Mainnet",
65+
curator: "K3",
66+
poolType: ["stable"],
67+
},
68+
{
69+
name: "DAI v3",
70+
address: "0xe7146f53dbcae9d6fa3555fe502648deb0b2f823",
71+
chainId: 1,
72+
network: "Mainnet",
73+
curator: "Chaos Labs",
74+
poolType: ["stable"],
75+
},
76+
{
77+
name: "GHO v3",
78+
address: "0x4d56c9cba373ad39df69eb18f076b7348000ae09",
79+
chainId: 1,
80+
network: "Mainnet",
81+
curator: "Chaos Labs",
82+
poolType: ["stable"],
83+
},
84+
{
85+
name: "Trade WBTC v3",
86+
address: "0xda00010eda646913f273e10e7a5d1f659242757d",
87+
chainId: 1,
88+
network: "Mainnet",
89+
curator: "Chaos Labs",
90+
poolType: ["btc"],
91+
},
92+
{
93+
name: "Trade tBTC v3",
94+
address: "0x7354ec6e852108411e681d13e11185c3a2567981",
95+
chainId: 1,
96+
network: "Mainnet",
97+
curator: "Chaos Labs",
98+
poolType: ["btc"],
99+
},
100+
{
101+
name: "Re7 tBTC",
102+
address: "0xf791ecc5f2472637eac9dfe3f7894c0b32c32bdf",
103+
chainId: 1,
104+
network: "Mainnet",
105+
curator: "Re7",
106+
poolType: ["btc"],
107+
},
108+
{
109+
name: "crvUSD v3",
110+
address: "0x8ef73f036feec873d0b2fd20892215df5b8bdd72",
111+
chainId: 1,
112+
network: "Mainnet",
113+
curator: "Chaos Labs",
114+
poolType: ["stable"],
115+
},
116+
{
117+
name: "Trade DOLA v3",
118+
address: "0x31426271449f60d37cc5c9aef7bd12af3bdc7a94",
119+
chainId: 1,
120+
network: "Mainnet",
121+
curator: "Chaos Labs",
122+
poolType: ["stable"],
123+
},
124+
{
125+
name: "WETH v3",
126+
address: "0x42db77b3103c71059f4b997d6441cfb299fd0d94",
127+
chainId: 10,
128+
network: "Optimism",
129+
curator: "Chaos Labs",
130+
poolType: ["eth"],
131+
},
132+
{
133+
name: "Main USDC v3",
134+
address: "0xa210bb193ca352fa81fbd0e81cb800580b0762ee",
135+
chainId: 10,
136+
network: "Optimism",
137+
curator: "Chaos Labs",
138+
poolType: ["stable"],
139+
},
140+
{
141+
name: "Main USDC.e v3",
142+
address: "0x5520daa93a187f4ec67344e6d2c4fc9b080b6a35",
143+
chainId: 10,
144+
network: "Optimism",
145+
curator: "Chaos Labs",
146+
poolType: ["stable"],
147+
},
148+
{
149+
name: "Chaos Labs USDT",
150+
address: "0xe773eb1c9c26e79deb8e20be24629953ce20597d",
151+
chainId: 56,
152+
network: "BNB",
153+
curator: "Chaos Labs",
154+
poolType: ["stable"],
155+
},
156+
{
157+
name: "WBNB v3",
158+
address: "0xef7d781825350d2bacb64ef7be927fd400dcdf4f",
159+
chainId: 56,
160+
network: "BNB",
161+
curator: "Chaos Labs",
162+
poolType: ["wbnb"],
163+
},
164+
{
165+
name: "USD1 V3 Pool",
166+
address: "0x1318b920704295e8c53f950cd429c3e40335b81d",
167+
chainId: 56,
168+
network: "BNB",
169+
curator: "Chaos Labs",
170+
poolType: ["stable"],
171+
},
172+
{
173+
name: "wS v3 Sonic",
174+
address: "0xcf4d737c38ef2ac9c7bdb4dbbc954b1932ea4a40",
175+
chainId: 146,
176+
network: "Sonic",
177+
curator: "Chaos Labs",
178+
poolType: ["s"],
179+
},
180+
{
181+
name: "USDC.e v3 Sonic",
182+
address: "0x6f6bda069fb05bab5e83b22fbdb54cbdf33f78ee",
183+
chainId: 146,
184+
network: "Sonic",
185+
curator: "Chaos Labs",
186+
poolType: ["stable"],
187+
},
188+
{
189+
name: "Re7 WETH",
190+
address: "0xa16952191248e6b4b3a24130dfc47f96ab1956a7",
191+
chainId: 1135,
192+
network: "Lisk",
193+
curator: "Re7",
194+
poolType: ["eth"],
195+
},
196+
{
197+
name: "Main WETH v3",
198+
address: "0x04419d3509f13054f60d253e0c79491d9e683399",
199+
chainId: 42161,
200+
network: "Arbitrum",
201+
curator: "Chaos Labs",
202+
poolType: ["eth"],
203+
},
204+
{
205+
name: "Main USDC v3",
206+
address: "0x890a69ef363c9c7bdd5e36eb95ceb569f63acbf6",
207+
chainId: 42161,
208+
network: "Arbitrum",
209+
curator: "Chaos Labs",
210+
poolType: ["stable"],
211+
},
212+
{
213+
name: "Main USDC.e v3",
214+
address: "0xa76c604145d7394dec36c49af494c144ff327861",
215+
chainId: 42161,
216+
network: "Arbitrum",
217+
curator: "Chaos Labs",
218+
poolType: ["stable"],
219+
},
220+
{
221+
name: "USDC Test",
222+
address: "0x05a11216171d1018af921d1d79d838cfb4576680",
223+
chainId: 42793,
224+
network: "Etherlink",
225+
curator: "Re7",
226+
poolType: ["stable"],
227+
},
228+
{
229+
name: "hemiBTC pool - bfBTC looping collateral",
230+
address: "0xd172b64aa13d892bb5eb35f3482058eae0bc5b2a",
231+
chainId: 43111,
232+
network: "Hemi",
233+
curator: "Invariant Group",
234+
poolType: ["hemiBTC"],
235+
},
236+
{
237+
name: "USDC.e - wBTC, hemiBTC and ETH",
238+
address: "0x614eb485de3c6c49701b40806ac1b985ad6f0a2f",
239+
chainId: 43111,
240+
network: "Hemi",
241+
curator: "Invariant Group",
242+
poolType: ["stable"],
243+
},
244+
];

0 commit comments

Comments
 (0)