-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdepositSavingsRate.ts
47 lines (35 loc) · 1.46 KB
/
depositSavingsRate.ts
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
import { getContractsFactory } from '../../../src/index';
const daiToken = getContractsFactory('eth').getContract('StandardERC20').instance('dai');
const dsrManager = getContractsFactory('eth').getContract('DsrManager').instance();
// TODO: Set your own address here -- this is the address who can withdraw DAI from the DSR
const ownerAddress = '0x0000000000000000000000000000000000000000';
// TODO: Set the desired amount of DAI to deposit in base units, so 1e18 is 1 DAI
const depositAmount = 1e18;
/*
* ============================================ //
* ============================================ //
*/
// First We need to approve ownership of some of our DAI to the DSR Manager
let { data, amount } = daiToken.methods()
.approve.call({
_spender: dsrManager.address,
_value: depositAmount.toString(10),
});
console.log(`\nTo approve ${depositAmount} DAI base units to the DSR Manager, send:`);
console.log(`Data: ${data}`);
console.log(`Amount: ${amount} ETH`);
console.log(`To: ${daiToken.address}`);
/*
* ============================================ //
* ============================================ //
*/
// Now we can actually deposit it and get the DSR
({ data, amount } = dsrManager.methods()
.join.call({
dst: ownerAddress,
wad: depositAmount.toString(10),
}));
console.log(`\nTo deposit ${depositAmount} DAI base units into the DSR`);
console.log(`Data: ${data}`);
console.log(`Amount: ${amount} ETH`);
console.log(`To: ${dsrManager.address}`);