From 4fd4d67426ac5a1b7985ef64beb01da6b65b3011 Mon Sep 17 00:00:00 2001 From: Gonzalo Balabasquer Date: Mon, 2 Sep 2019 15:13:15 -0300 Subject: [PATCH] Update to version 0.2.12 --- libexec/mcd/conf/kovan.json | 99 ++++++++++++++++++--------------- libexec/mcd/mcd---proxy-address | 6 +- libexec/mcd/mcd---proxy-exec | 2 +- libexec/mcd/mcd-cdp | 27 +++++---- libexec/mcd/mcd-cdp-cmd | 63 ++++++++++++++++++--- libexec/mcd/mcd-cdp-open | 8 +-- libexec/mcd/mcd-urn | 36 ++++++------ 7 files changed, 149 insertions(+), 92 deletions(-) diff --git a/libexec/mcd/conf/kovan.json b/libexec/mcd/conf/kovan.json index b9a3108..360e6cd 100644 --- a/libexec/mcd/conf/kovan.json +++ b/libexec/mcd/conf/kovan.json @@ -1,76 +1,83 @@ { "DEPLOYER": "0x61de44946D6b809a30D8e6A236157966659f9640", - "MULTICALL": "0x34b5bd422b27a8c8eaf3f80b940367d975c8f6e1", + "MULTICALL": "0x45cb578f91fd7e1ebcf910d270814c7ddf9c3bdd", "FAUCET": "0x94598157fcf0715c3bc9b4a35450cce82ac57b20", - "MCD_DEPLOY": "0x6146433a8ec1ac6cf100acf2ab09a81912393ed2", + "MCD_DEPLOY": "0x8d02bab52dc69f473b7ab65fc3b608c1d92746bd", "MCD_GOV": "0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd", - "MCD_GUARD": "0x0de879766490e497025738ae29bb8cc533eb355d", - "MCD_ADM": "0x3d434d7625721aa31ddbf9f98825aca6ba4b685f", - "MCD_IOU": "0xc52362382417f56e85e7e030b786972a1a2edd0b", - "VOTE_PROXY_FACTORY": "0x984c18e3f8a8582cedaa5b96e2c7399f0a2b022b", - "MCD_VAT": "0x04c67ea772ebb467383772cb1b64c7a9b1e02bca", - "MCD_JUG": "0xeffb135cf2e4911de9e478679d358c9df246424a", - "MCD_CAT": "0x505795bd482f24da52bba25c072a833696d8c6ee", - "MCD_VOW": "0x5fd6598a1f6a3b5fe78627fa72107d4a9fadf348", - "MCD_JOIN_DAI": "0xcf20652c7e9ff777fcb3772b594e852d1154174d", - "MCD_FLAP": "0x43920251323f05139c76bd75771fd3ab8e5a6dad", - "MCD_FLOP": "0xd5f64f76ce8047e8978707a00fa4c143405e9e37", - "MCD_PAUSE": "0xb5bb144eb951a8060d6ac186aee694187e2d037d", - "MCD_PAUSE_PROXY": "0xd16ba625e0b981c73fba249db64b523eade884a4", - "MCD_GOV_ACTIONS": "0xed0150fc2eb6f280af552fbdf3cbd5f66d3c7d1f", - "MCD_DAI": "0xdb6a55a94e0dd324292f3d05cf504c751b31cee2", - "MCD_SPOT": "0x2403ddca8715427fdb04f9e70d8989cddab06b67", - "MCD_POT": "0xe019a058adcd42e34a456f3b86466ddd103027e4", - "MCD_END": "0xdf72153215205ae87b4cf388866064ce234b35a5", - "MCD_ESM": "0xce1db78a9d5ff7520430421f8fa5f7744021dd3e", - "PROXY_ACTIONS": "0x4e8fa882ce2127b50e508d3abfa6be12911b0c05", - "CDP_MANAGER": "0x7a4991c6bd1053c31f1678955ce839999d9841b1", - "GET_CDPS": "0xcc1ba3ee9cd1e06765ae41a195723bbe97de4ed1", + "MCD_GUARD": "0x9b265d2abc5248389f0e603963d22141304f7b18", + "MCD_ADM": "0xbe4bc5ed0bd879327e161ae57b8d59bb103bf56c", + "MCD_IOU": "0xe7f374ef2dfa4f33d99fa8237749fbf69532a867", + "VOTE_PROXY_FACTORY": "0xa3b66ac8d0b621a406b9f974ec68badd45bb18ef", + "MCD_VAT": "0xdf69460542dbdcf2f1e77941f53cfd4113a06183", + "MCD_JUG": "0x269b2ca90b8f5d8e0a78ec9e1ea43ec41f7d1477", + "MCD_CAT": "0xb30432fc29e1479240e9f107c1e333b962998f06", + "MCD_VOW": "0x022688b43bf76a9e6f4d3a96350ffde90a752d25", + "MCD_JOIN_DAI": "0x922253e8bb9905ae4d37bc9bd512db5c91b5ee6c", + "MCD_FLAP": "0x2f03d50e1fa1768b2c627e683d940911eea4449b", + "MCD_FLOP": "0xd86a529f008c092009334f0ea975e01d6d2dbf9a", + "MCD_PAUSE": "0x7c05a46d96a125ee8f084f600f33cd6432c48400", + "MCD_PAUSE_PROXY": "0xf11469b79f4836e53a63447f019d1806aaa749dc", + "MCD_GOV_ACTIONS": "0x05c0d17607d0b048fc7b4749be73f11698461a4b", + "MCD_DAI": "0xb64964e9c0b658aa7b448cdbddfcdccab26cc584", + "MCD_SPOT": "0xb61db7923f841740c96b24baec4805e522bb8594", + "MCD_POT": "0xe8fc4fc4d5ab7fa20be296277ef157a8b0ec20ce", + "MCD_END": "0xeb9df03edf12619648911b5101d911ebb3527adc", + "MCD_ESM": "0x509628df09de9b86af6650f90978412ed95c148d", + "PROXY_ACTIONS": "0xad5e4a739e950ee591861d034090c2b1e232dc15", + "CDP_MANAGER": "0x093a6036114813f951c82929c171c2e415539ffa", + "GET_CDPS": "0x672fa0c6ebe0bc93fc78acc064212181ac5a0c55", "PROXY_FACTORY": "0xe11e3b391f7e8bc47247866af32af67dd58dc800", "PROXY_REGISTRY": "0x64a436ae831c1672ae81f674cab8b6775df3475c", "ETH": "0xd0a1e359811322d97991e03f863a0c30c2cf029c", "VAL_ETH": "0x75dd74e8afe8110c8320ed397cccff3b8134d981", "PIP_ETH": "0x75dd74e8afe8110c8320ed397cccff3b8134d981", - "MCD_JOIN_ETH_A": "0x004ddbf22b90cc5ce715be6096ac2fd89b514bf6", - "MCD_FLIP_ETH_A": "0xe8b1439bbcc5a4da4a8e938257aea3a8d18f78ad", - "MCD_JOIN_ETH_B": "0xb3acc117e70e9f2cb8afa66c80ed5ffc09df9c70", - "MCD_FLIP_ETH_B": "0xd4b18bbc581fa6f7a019c7c8f2245430f865c14e", - "MCD_JOIN_ETH_C": "0xade09cccddbacfdd69741c97a45d742460e9ec23", - "MCD_FLIP_ETH_C": "0x965875bddaa6011a8af54cb952798473bc0f086b", + "MCD_JOIN_ETH_A": "0xc6d2c6ac2155461d41621eac97ca0e42cd8c6805", + "MCD_FLIP_ETH_A": "0x02b6c914e29ee4d310e6b8e24340a8a643627d44", + "MCD_JOIN_ETH_B": "0xcf9a5fe859b4797630141f156c597281d824d62d", + "MCD_FLIP_ETH_B": "0x30a1d49da153d12bb74e3a273a21850a1e484a45", + "MCD_JOIN_ETH_C": "0x3b8ed141f5961ba98527f30723cd90c028c4ec94", + "MCD_FLIP_ETH_C": "0xc7fd00f35e77f40034a775feb88cbc6e4e88fbbc", "REP": "0xc7aa227823789e363f29679f23f7e8f6d9904a9b", "VAL_REP": "0x5debc8c4124db0c1d3bad99e69287a576c7b2ccc", "PIP_REP": "0x5debc8c4124db0c1d3bad99e69287a576c7b2ccc", - "MCD_JOIN_REP_A": "0x91f4e07be74445a3897b6d4e70393b5ad7b8e4b0", - "MCD_FLIP_REP_A": "0x01d7735e4a4cadadb1f1ec5e7fe08f676ec17ed2", + "MCD_JOIN_REP_A": "0x2c205dd1a49b17d24062e72b2fd4585c643359fb", + "MCD_FLIP_REP_A": "0x4ef2bede48b106151e75b58ee73c85a4ef444adc", "ZRX": "0x18392097549390502069c17700d21403ea3c721a", "VAL_ZRX": "0xc010f1bbde279a5bb05c93f5fc902293d5a9f7a9", "PIP_ZRX": "0xc010f1bbde279a5bb05c93f5fc902293d5a9f7a9", - "MCD_JOIN_ZRX_A": "0x4a48d3e3ee832575f70efb980c9a62ddce5c263a", - "MCD_FLIP_ZRX_A": "0x5ce206c55d6c13fe9293a947b43a0dcd3e6ef137", + "MCD_JOIN_ZRX_A": "0x3d030db261162992484efad43174fce231b0984c", + "MCD_FLIP_ZRX_A": "0xb08a9c38f184c7e0b7468e6fb3923a1121a23cb0", "OMG": "0x441b1a74c69ee6e631834b626b29801d42076d38", "VAL_OMG": "0x1e9740f61e80650a60ba70f2d0b477fb85db2b03", "PIP_OMG": "0x1e9740f61e80650a60ba70f2d0b477fb85db2b03", - "MCD_JOIN_OMG_A": "0x606fcf8eb5bbe1dd17d52d853c7d346c594109fe", - "MCD_FLIP_OMG_A": "0xc967ff09e407ec029cb98f42f8e628116407085b", + "MCD_JOIN_OMG_A": "0x7ee813838fb9eef4b46ea1756380e16f2db51669", + "MCD_FLIP_OMG_A": "0x3f3fea4e1e8a21c0517eccb034b97ea7756ecea4", "BAT": "0x9f8cfb61d3b2af62864408dd703f9c3beb55dff7", "VAL_BAT": "0x5c40c9eb35c76069fa4c3a00ea59fac6ffa9c113", "PIP_BAT": "0x5c40c9eb35c76069fa4c3a00ea59fac6ffa9c113", - "MCD_JOIN_BAT_A": "0x635716849a7f6ae57211bb2f9564b10551a8f166", - "MCD_FLIP_BAT_A": "0x5bc5be4775eb6c61bff9717e1f35d887fb54142c", + "MCD_JOIN_BAT_A": "0x9ca955e44ebdd69d070e4a62653b73d82b4e82ba", + "MCD_FLIP_BAT_A": "0x7b0f4c12003ab881ecc11d9d12f15d3f8fe9fcff", "DGD": "0x62aeec5fb140bb233b1c5612a8747ca1dc56dc1b", "VAL_DGD": "0x112bf99e873317643fbfcc22d197e3e01b825cb0", "PIP_DGD": "0x112bf99e873317643fbfcc22d197e3e01b825cb0", - "MCD_JOIN_DGD_A": "0xf07b0cbe6fad45bb3576de92e063639ad951987f", - "MCD_FLIP_DGD_A": "0x034f2c3e4e8db8f8469493bb38d8885e06f8ab54", + "MCD_JOIN_DGD_A": "0xc269c2b400f560668ec15d04767607f60be46947", + "MCD_FLIP_DGD_A": "0x2768a3436d51fd7b6f0ef002b46912e423920721", "GNT": "0xc81ba844f451d4452a01bbb2104c1c4f89252907", "VAL_GNT": "0xf46e96a6f23fdcb5870f0ac0dbe9d2c605485ddc", "PIP_GNT": "0xf46e96a6f23fdcb5870f0ac0dbe9d2c605485ddc", - "MCD_JOIN_GNT_A": "0x4e22282bb7304c6c07aa4404b3a9a2f7afe1958a", - "MCD_FLIP_GNT_A": "0xa1a4cc927091a3c9f10e55a161869b3cad58ef1b", - "PROXY_PAUSE_ACTIONS": "0x640457c680d75dae73450a642c41cd178d34ac65", + "MCD_JOIN_GNT_A": "0xb8dbbd75ebf7de71815177ff43b809c428702260", + "MCD_FLIP_GNT_A": "0xb831251366a991f8a867f7f3bb1c720a7e12900f", + "SAI": "0xc4375b7de8af5a38a93548eb8453a498222c4ff2", + "PIP_SAI": "0x0000000000000000000000000000000000000001", + "MCD_JOIN_SAI": "0x92424ca1df17c48d6be8448173bb10366120df0b", + "MCD_FLIP_SAI": "0x2f4e4a5507db5dc4e07bb949cbb0135b06f9885c", + "PROXY_PAUSE_ACTIONS": "0x317e4d435a9c067529b985aa55fce8a92153f0fd", "PROXY_DEPLOYER": "0x818a81dd914e89a4698869ee54c8e2c056bfda03", - "GOV_POLL_GEN": "0xd247195403963d7b81ff0028d1036d7ed0ed61a3", + "SAI_TUB": "0xa71937147b55deb8a530c7229c442fd3f31b7db2", + "MIGRATION": "0x1276d811b96bfa2413a28ff062eb854e42af94f5", + "MIGRATION_PROXY_ACTIONS": "0x53283da4dddac7cda87fd01458c6ceed32451b21", + "GOV_POLL_GEN": "0x9211500996c12f833574ec6819ba0a87227fd840", "POLL_ID": "0", - "VOTE_YES": "0x6e1c3b0334ef4231dd739d1e0e2f9cf2ec0fdb4a", - "VOTE_NO": "0x80ba5974a57033ccb1a4e6982ae32a255cd24f5f" + "VOTE_YES": "0x6f0710bf5fd566933ee3f3fd17c7c859ddb0eedd", + "VOTE_NO": "0x7995d41a52e5f7145aca41e6d9cdde30323342f6" } diff --git a/libexec/mcd/mcd---proxy-address b/libexec/mcd/mcd---proxy-address index 93c6d6b..c29b9e9 100755 --- a/libexec/mcd/mcd---proxy-address +++ b/libexec/mcd/mcd---proxy-address @@ -3,14 +3,14 @@ set -e if [[ -z "$MCD_PROXY_ADDRESS" ]]; then sig="proxies(address)(address)" - proxy=0x$(seth call ${PROXY_REGISTRY?} $sig $ETH_FROM) + proxy=0x$(seth call "${PROXY_REGISTRY?}" $sig "$ETH_FROM") else proxy=$MCD_PROXY_ADDRESS fi -if [[ $(seth --to-dec $proxy) -eq 0 ]]; then +if [[ $(seth --to-dec "$proxy") -eq 0 ]]; then proxy=$(mcd --proxy-build) fi export MCD_PROXY_ADDRESS=$proxy -echo $proxy +echo "$proxy" diff --git a/libexec/mcd/mcd---proxy-exec b/libexec/mcd/mcd---proxy-exec index 5b15727..54ec6f9 100755 --- a/libexec/mcd/mcd---proxy-exec +++ b/libexec/mcd/mcd---proxy-exec @@ -3,4 +3,4 @@ set -e proxy=$(mcd --proxy-address) bytes=$(seth calldata "${@}") sig="execute(address,bytes memory)" -seth send $proxy "$sig" "${PROXY_ACTIONS?}" "$bytes" +seth send "$proxy" "$sig" "${PROXY_ACTIONS?}" "$bytes" diff --git a/libexec/mcd/mcd-cdp b/libexec/mcd/mcd-cdp index f78e4f0..ce6bc5c 100755 --- a/libexec/mcd/mcd-cdp +++ b/libexec/mcd/mcd-cdp @@ -2,18 +2,21 @@ ### mcd-cdp -- CDP managerment ### Usage: mcd cdp [] [] ### -### Commands: ls [] List Cdps -### count [] Cdp count -### open Open a new Cdp -### urn Cdp state -### lock Join & lock standard gem collateral -### safe-lock Join & safely lock standard gem collateral (checks it is your CDP) -### free Free & exit standard gem collateral -### draw Draw & exit dai -### wipe Join & wipe dai -### safe-wipe Join & wipe dai -### give
Give a Cdp to another owner -### quit
Convert a Cdp to native Urn +### Commands: ls [] List Cdps +### count [] Cdp count +### open Open a new Cdp +### urn Cdp state +### lock Join & lock standard gem collateral +### safe-lock Join & safely lock standard gem collateral (checks it is your CDP) +### free Free & exit standard gem collateral +### draw Draw & exit dai +### wipe Join & wipe dai +### safe-wipe Join & wipe dai (checks it is your CDP) +### wipe-all Join & wipe dai to leave debt=0 +### safe-wipe-all Join & wipe dai to leave debt=0 (checks it is your CDP) +### give
Give a Cdp to another owner +### give-to-proxy
Give a Cdp to the proxy of another owner (it will create the proxy if doesn't exist) +### quit
Convert a Cdp to native Urn set -e shopt -s extglob diff --git a/libexec/mcd/mcd-cdp-cmd b/libexec/mcd/mcd-cdp-cmd index 4dd9830..680b846 100755 --- a/libexec/mcd/mcd-cdp-cmd +++ b/libexec/mcd/mcd-cdp-cmd @@ -8,7 +8,6 @@ act=$1; shift; MCD_ILK=$(mcd --to-ascii "$ilk") export MCD_ILK -export ETH_GAS=${ETH_GAS:-500000} require-wad() { [ -n "$1" ] || mcd --fail "mcd-cdp: Please specify an amount to $act" @@ -17,6 +16,7 @@ require-wad() { case $act in lock) { + export ETH_GAS=${ETH_GAS:-300000} require-wad "$1" mcd --gem-approve "$MCD_PROXY" "$1" sig="lockGem(address,address,uint,uint,bool)" @@ -25,6 +25,7 @@ case $act in [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn };; safe-lock) { + export ETH_GAS=${ETH_GAS:-300000} require-wad "$1" mcd --gem-approve "$MCD_PROXY" "$1" sig="safeLockGem(address,address,uint,uint,bool)" @@ -33,6 +34,7 @@ case $act in [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn };; free) { + export ETH_GAS=${ETH_GAS:-200000} require-wad "$1" sig="freeGem(address,address,uint,uint)" mcd --proxy-exec $sig "${CDP_MANAGER?}" "$(mcd gem adapter)" "$hex" "$wad" @@ -40,6 +42,7 @@ case $act in [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn };; draw) { + export ETH_GAS=${ETH_GAS:-400000} require-wad "$1" sig="draw(address,address,address,uint,uint)" mcd --proxy-exec $sig "${CDP_MANAGER?}" "$MCD_JUG" "$MCD_JOIN_DAI" "$hex" "$wad" @@ -47,6 +50,7 @@ case $act in [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn };; wipe) { + export ETH_GAS=${ETH_GAS:-250000} require-wad "$1" export MCD_TOKEN=$MCD_DAI mcd --dai-approve "$MCD_PROXY" @@ -56,6 +60,7 @@ case $act in [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn };; safe-wipe) { + export ETH_GAS=${ETH_GAS:-250000} require-wad "$1" export MCD_TOKEN=$MCD_DAI mcd --dai-approve "$MCD_PROXY" @@ -64,7 +69,26 @@ case $act in [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn };; + wipe-all) { + export ETH_GAS=${ETH_GAS:-250000} + export MCD_TOKEN=$MCD_DAI + mcd --dai-approve "$MCD_PROXY" + sig="wipeAll(address,address,uint)" + mcd --proxy-exec $sig "${CDP_MANAGER?}" "$MCD_JOIN_DAI" "$hex" + + [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn + };; + safe-wipe-all) { + export ETH_GAS=${ETH_GAS:-250000} + export MCD_TOKEN=$MCD_DAI + mcd --dai-approve "$MCD_PROXY" + sig="safeWipeAll(address,address,uint)" + mcd --proxy-exec $sig "${CDP_MANAGER?}" "$MCD_JOIN_DAI" "$hex" + + [[ $SETH_ASYNC != yes ]] && mcd cdp "$cdp" urn + };; give) { + export ETH_GAS=${ETH_GAS:-200000} lad=$(seth --to-address "$1") echo "from: $(mcd cdp "$cdp" lad) to: $lad" echo "Warning: only give to a proxy that you control!" @@ -77,19 +101,40 @@ case $act in *) { exit 1; };; esac };; + give-to-proxy) { + export ETH_GAS=${ETH_GAS:-800000} + lad=$(seth --to-address "$1") + echo "from: $(mcd cdp "$cdp" lad) to: $lad's proxy" + echo "Warning: only give to a wallet that you control and can handle proxies!" + read -r -p "Continue? [Y/n]: " response + case $response in + [yY]) { + sig="giveToProxy(address,address,uint,address)" + mcd --proxy-exec $sig "${PROXY_REGISTRY?}" "${CDP_MANAGER?}" "$hex" "$lad" + };; + *) { exit 1; };; + esac + };; quit) { + export ETH_GAS=${ETH_GAS:-300000} dst=$(seth --to-address "$1") - urn=$(seth call "${CDP_MANAGER?}" 'urns(uint)(address)' "$hex") - sig="can(address,address)(uint)" - can=$(seth call "$MCD_VAT" "$sig" "$urn" "$dst") - if [[ $(seth --to-dec "$can") -eq 1 ]]; then - mcd --proxy-exec 'quit(uint,address)' "$hex" "$dst" - else - echo >&2 "Error: destination urn must be trusted" + can=$(seth call "$MCD_VAT" "can(address,address)(uint)" "$dst" "${CDP_MANAGER?}") + if [[ $(seth --to-dec "$can") -eq 0 ]]; then + echo >&2 "Error: Cdp Manager must be trusted for dst urn (in the Vat)" + exit 1 + fi + proxy=$(mcd --proxy-address) + if [[ "$dst" != "$proxy" ]]; then + canUrn=$(seth call "$CDP_MANAGER" "urnCan(address,address)(uint)" "$dst" "$proxy") + if [[ $(seth --to-dec "$canUrn") -eq 0 ]]; then + echo >&2 "Error: Sender must be trusted for dst urn (in the Cdp Manager)" + exit 1 + fi fi + mcd --proxy-exec 'quit(address,uint,address)' "${CDP_MANAGER?}" "$hex" "$dst" };; lad) { - sig="lads(uint)(address)" + sig="owns(uint)(address)" echo "0x$(seth call "${CDP_MANAGER?}" "$sig" "$hex")" };; owner) { diff --git a/libexec/mcd/mcd-cdp-open b/libexec/mcd/mcd-cdp-open index 57061a8..afc3edb 100755 --- a/libexec/mcd/mcd-cdp-open +++ b/libexec/mcd/mcd-cdp-open @@ -3,11 +3,11 @@ set -e ilk=$(mcd --get-ilk) export SETH_ASYNC=yes -export ETH_GAS=${ETH_GAS:-250000} +export ETH_GAS=${ETH_GAS:-300000} usr=$(mcd --proxy-address) sig="open(address,bytes32)" -tx=$(mcd --proxy-exec $sig ${CDP_MANAGER?} $ilk) +tx=$(mcd --proxy-exec "$sig" "${CDP_MANAGER?}" "$ilk") echo >&2 -n "${0##*/}: Waiting for transaction receipt..." block=$(SETH_ASYNC=no SETH_TICK=true seth receipt "$tx" blockNumber) @@ -22,7 +22,7 @@ logs=$(seth rpc eth_getLogs -- \ -s "$block" -i toBlock \ -n [] \ -s "$sig" -i append \ - -s "0x$(seth --to-word $usr)" -i append \ + -s "0x$(seth --to-word "$usr")" -i append \ -i topics \ -i append | echo "[$(paste -sd , -)]") hex=$(echo "$logs" | jshon -a -e data -u) @@ -30,7 +30,7 @@ hash=$(echo "$logs" | jshon -a -e transactionHash -u) if [ "$hash" == "$tx" ]; then echo "$tx" - echo "Opened: cdp $(seth --to-dec $hex)" + echo "Opened: cdp $(seth --to-dec "$hex")" else echo >&2 "${0##*/}: Transaction failed." seth >&2 receipt "$tx" diff --git a/libexec/mcd/mcd-urn b/libexec/mcd/mcd-urn index 228b6e6..dadac76 100755 --- a/libexec/mcd/mcd-urn +++ b/libexec/mcd/mcd-urn @@ -9,12 +9,12 @@ ### With `` get a specified Urn parameter set -e -URN=$(mcd --get-urn $0) +URN=$(mcd --get-urn "$0") ILK=$(mcd --get-ilk) -vat() { mcd --vat-urn $ILK $URN; } +vat() { mcd --vat-urn "$ILK" "$URN"; } -p() { printf "%-4s %-42s %-10s\n" "$1" "$2" "$3"; } +p() { printf "%-4s %-48s %-10s\n" "$1" "$2" "$3"; } calc() { exec 3< <(mcd ilk spot) @@ -22,32 +22,34 @@ calc() { spot=$(cat <&3); rate=$(cat <&4); rat=0; rap=0; tab=0 - if [ ${art:0:1} -gt 0 ]; then - tab=$(printf '%.27f\n' $(bc <<< "$art*$rate")) - rap=$(printf '%.27f\n' $(bc <<< "$tab - $art")) + if [ "${art:0:1}" -gt 0 ]; then + tab=$(printf '%.27f\n' "$(bc <<< "$art*$rate")") + rap=$(printf '%.27f\n' "$(bc <<< "$tab - $art")") rat=$(bc <<< "scale=2; (($ink*$spot)/$tab)") fi } mcd-urn() { - p "ilk" $MCD_ILK "Collateral type" - p "urn" $URN "Urn handler" + p "ilk" "$MCD_ILK" "Collateral type" + p "urn" "$URN" "Urn handler" ink=$(mcd urn ink) art=$(mcd urn art) - p "ink" $ink "Locked collateral ($(mcd gem symbol))" - p "art" $art "Issued debt (Dai)" + dai=$(mcd dai balance vat --urn="$URN") + p "ink" "$ink" "Locked collateral ($(mcd gem symbol))" + p "art" "$art" "Issued debt (Dai)" + p "dai" "$dai" "Free Dai (in Vat)" calc - p "tab" $tab "Outstanding debt (Dai)" - p "rap" $rap "Accumulated stability fee (Dai)" - p "-->" $rat "Collateralization ratio" + p "tab" "$tab" "Outstanding debt (Dai)" + p "rap" "$rap" "Accumulated stability fee (Dai)" + p "-->" "$rat" "Collateralization ratio" echo - p "spot" $spot "$(mcd gem symbol) price with safety mat (USD)" - p "rate" $rate "$(mcd gem symbol) DAI exchange rate" + p "spot" "$spot" "$(mcd gem symbol) price with safety mat (USD)" + p "rate" "$rate" "$(mcd gem symbol) DAI exchange rate" } case $1 in - ink) vat | mcd --to-wad $(awk '{print $1}'); ;; - art) vat | mcd --to-wad $(awk '{print $2}'); ;; + ink) vat | mcd --to-wad "$(awk '{print $1}')"; ;; + art) vat | mcd --to-wad "$(awk '{print $2}')"; ;; spot) mcd urn spot; ;; # alias for consistency rate) mcd urn rate; ;; # alias for consistency "") mcd-urn; ;;