-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerate_base.py
38 lines (28 loc) · 967 Bytes
/
generate_base.py
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
#!/usr/bin/env python
from pathlib import Path
import shutil
import sys
import os
if len(sys.argv) < 2:
print("Pool name argument is required.")
print("Example: `python generate.py usd`")
exit(1)
poolName = sys.argv[1]
templatePath = Path('./contracts/pool-templates/base/SwapTemplateBase.vy')
sourceCode = open(templatePath).read()
poolDir = Path('./contracts/pools').joinpath(poolName)
if not os.path.exists(poolDir):
print("Pool directory not exist: ", poolDir)
exit(1)
targetContractPath = poolDir.joinpath('StableSwap' + poolName.upper() + ".vy")
exec(open("brownie_hooks.py").read())
poolFile = open(targetContractPath, 'w')
poolFile.write(brownie_load_source(templatePath, sourceCode))
poolFile.close()
# Copy base template pooldata to pool dir
shutil.copy(
'./contracts/pool-templates/base/pooldata.json',
'./contracts/pools/usd/pooldata.json'
)
print("Success")
print("Pool contract generated at: ", targetContractPath)