Skip to content

Instantly share code, notes, and snippets.

@tamccall
Last active February 7, 2020 04:19
Show Gist options
  • Save tamccall/fd2486bd13031de0d8cf46fe1089e6bb to your computer and use it in GitHub Desktop.
Save tamccall/fd2486bd13031de0d8cf46fe1089e6bb to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const McdPlugin = require("@makerdao/dai-plugin-mcd");
const Maker = require("@makerdao/dai");
async function main() {
const maker = await Maker.create('http', {
// the usual configuration options go here...
plugins: [
[McdPlugin, {}] // the second argument can be used to pass options to the plugin
]
});
const manager = maker.service('mcd:cdpManager');
const proxyAddress = maker.service('proxy').currentProxy();
const data = await manager.getCdpIds(proxyAddress); // returns list of { id, ilk } objects
const vault = await manager.getCdp(data[0].id);
console.log([
vault.collateralAmount,
vault.collateralValue, // value in USD given current price feed values
vault.debtValue,
vault.collateralizationRatio,
vault.liquidationPrice
].map(x => x.toString()));
}
main().catch(e => console.log("error in main:\n", e));
@tamccall
Copy link
Author

tamccall commented Feb 7, 2020

 2020-02-06 20:15:28 ⌚  Andys-MBP in ~/workspace/dai
○ → node .
error in main:
 AssertionError [ERR_ASSERTION]: plugins[0] does not seem to be a plugin
    at /Users/andy/workspace/dai/node_modules/@makerdao/dai/dist/src/Maker.js:350:28
    at Array.map (<anonymous>)
    at standardizePluginConfig (/Users/andy/workspace/dai/node_modules/@makerdao/dai/dist/src/Maker.js:341:18)
    at _callee$ (/Users/andy/workspace/dai/node_modules/@makerdao/dai/dist/src/Maker.js:249:29)
    at tryCatch (/Users/andy/workspace/dai/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/Users/andy/workspace/dai/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (/Users/andy/workspace/dai/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/Users/andy/workspace/dai/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/Users/andy/workspace/dai/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /Users/andy/workspace/dai/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at Function.create (/Users/andy/workspace/dai/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12)
    at main (/Users/andy/workspace/dai/index.js:7:29)
    at Object.<anonymous> (/Users/andy/workspace/dai/index.js:27:1)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment