-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (44 loc) · 1.42 KB
/
app.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
56
require('dotenv').config();
const NodeMaker = require('./index');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider(process.env.RPC_URL));
const nodeMaker = new NodeMaker({
chain: 'kovan',
address: process.env.address,
web3: web3
});
(async () => {
try{
console.log(`Current Price of Eth: ${await nodeMaker.getEthPrice()}`);
console.log('--------------------------------');
const ethToCollateralize = new web3.utils.BN(1);
const daiToDraw = 10;
const wethWrapped = await nodeMaker.wrapEthToWeth(ethToCollateralize);
console.log('--------------------------------');
console.log('wethWrapped');
console.log(wethWrapped);
const joinWethToPeth = await nodeMaker.joinWethToPeth(ethToCollateralize);
console.log('--------------------------------');
console.log('joinWethToPeth');
console.log(joinWethToPeth);
const openCDP = await nodeMaker.openCDP();
console.log('--------------------------------');
console.log('openCDP');
console.log(openCDP);
const pethLocked = await nodeMaker.lockPeth(ethToCollateralize);
console.log('--------------------------------');
console.log('pethLocked');
console.log(pethLocked);
try{
const dai = await nodeMaker.drawDai(daiToDraw);
console.log('--------------------------------');
console.log('dai');
console.log(dai);
}catch(e){
console.log('Draw dai')
console.log(e)
}
}catch(e){
throw new Error(e);
}
})();