Last active
February 7, 2020 04:19
-
-
Save tamccall/fd2486bd13031de0d8cf46fe1089e6bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)); |
Author
tamccall
commented
Feb 7, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment