Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Updates after review:
Browse files Browse the repository at this point in the history
- updated usage command
- cleaned up script to only generate MDAI
- use absolute imports
- print account MDAI balance after generating MDAI
  • Loading branch information
grandizzy committed Dec 6, 2019
1 parent 9bda771 commit 210772c
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions scripts/generateDai.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// usage:
// > node_modules/.bin/babel-node scripts/fundTestAccount.js <address>
// > node_modules/.bin/babel-node scripts/fundTestAccount.js <address> <daiAmount>

import Maker from '../packages/dai/src';
import McdPlugin from '../packages/dai-plugin-mcd/src';
import { isAddress } from 'web3-utils';
import map from 'lodash/map';
import uniq from 'lodash/uniq';
import { MDAI, ETH } from '../packages/dai-plugin-mcd/src/index';
import { mcdMaker, setupCollateral } from '../packages/dai-plugin-mcd/test/helpers';
import { MDAI, ETH } from '@makerdao/dai-plugin-mcd/src/index';
import { mcdMaker } from '@makerdao/dai-plugin-mcd/test/helpers';

async function main() {
const maker = await mcdMaker();
Expand All @@ -19,18 +15,14 @@ async function main() {
}

maker.service('accounts').useAccountWithAddress(address);
const savingsService = maker.service('mcd:savings');
const dai = maker.getToken(MDAI);
const proxyAddress = await maker.service('proxy').ensureProxy();
process.stdout.write(`Proxy address ${proxyAddress} `);
await dai.approveUnlimited(proxyAddress);

console.log(`Generating DAI for ${address}`);
console.log(`Generating ${amount} MDAI for ${address}`);
const cdpMgr = maker.service('mcd:cdpManager');
await setupCollateral(maker, 'ETH-A', { price: 150, debtCeiling: 50 });

await cdpMgr.openLockAndDraw('ETH-A', ETH(1), MDAI(amount));

await maker.service('allowance').removeAllowance('MDAI', proxyAddress);
const dai = cdpMgr.get('token').getToken(MDAI);
const balance = await dai.balanceOf(address)
console.log(`Balance of ${address}: ${balance}`)

}

Expand Down

0 comments on commit 210772c

Please sign in to comment.