diff --git a/libexec/mcd/mcd-bite b/libexec/mcd/mcd-bite index 1d4c248..254bc5a 100755 --- a/libexec/mcd/mcd-bite +++ b/libexec/mcd/mcd-bite @@ -5,12 +5,12 @@ ### Specify the Ilk identifier and Urn address to bite. set -e -export ETH_GAS=${ETH_GAS:-250000} +export ETH_GAS=${ETH_GAS:-750000} ilk=$(mcd --get-ilk) urn=$(mcd --get-urn $0) -p() { printf "%-3s %-50s %-10s\n" "$1" "$2" "$3"; } +p() { printf "%-7s %-50s %-10s\n" "$1" "$2" "$3"; } sig="bite(bytes32,address)(uint256)" tx=$(seth send --async "${MCD_CAT?}" "$sig" "$ilk" "$urn") @@ -19,7 +19,7 @@ block=$(SETH_TICK=true seth receipt "$tx" blockNumber) block=$(seth --to-hex "$block") echo >&2 -sig="Bite(bytes32,address,uint256,uint256,uint256,uint256)" +sig="Bite(bytes32,address,uint256,uint256,uint256,address,uint256)" keccak=$(seth keccak "$(seth --from-ascii $sig)") logs=$(seth rpc eth_getLogs -- \ -n {} \ @@ -37,10 +37,11 @@ hash=$(echo "$logs" | jshon -a -e transactionHash -u) if [ "$hash" == "$tx" ]; then echo "$tx" - p "id" $(seth --to-dec 0x${data:196:64}) "Bite identifier" - p "ink" $(mcd --to-wad ${data:2:64}) "Seized collateral ($MCD_ILK)" - p "art" $(mcd --to-wad ${data:66:64}) "Seized debt (DAI)" - p "tab" $(mcd --to-rad ${data:130:64}) "Outstanding debt to auction" + p "ink" $(mcd --to-wad ${data:2:64}) "Seized collateral ($MCD_ILK)" + p "art" $(mcd --to-wad ${data:66:64}) "Seized debt (DAI)" + p "tab" $(mcd --to-rad ${data:130:64}) "Debt sent to auction" + p "flipper" "0x${data:218:40}" "Auction contract" + p "flip" $(seth --to-dec 0x${data:258:64}) "Bid identifier" else echo >&2 "${0##*/}: Transaction failed." seth >&2 receipt "$tx" diff --git a/libexec/mcd/mcd-bites b/libexec/mcd/mcd-bites index dbd9828..2e734f8 100755 --- a/libexec/mcd/mcd-bites +++ b/libexec/mcd/mcd-bites @@ -2,7 +2,7 @@ ### mcd-bites -- Recent bites ### Usage: mcd bites [-B ] [--ilk=] [--urn=
] set -e -sig="Bite(bytes32,address,uint256,uint256,uint256,uint256)" +sig="Bite(bytes32,address,uint256,uint256,uint256,address,uint256)" sig=$(seth keccak "$(seth --from-ascii $sig)") [[ "$MCD_ILK" ]] && ilk=0x$(seth --to-bytes32 $(seth --from-ascii "$MCD_ILK")) [[ "$MCD_URN" ]] && urn=0x$(seth --to-bytes32 "$MCD_URN") @@ -18,7 +18,8 @@ seth logs ${MCD_CAT?} "$sig" "$ilk" "$urn" | echo "ink $(mcd --to-wad ${data:2:64})" echo "art $(mcd --to-wad ${data:66:64})" echo "tab $(mcd --to-rad ${data:130:64})" - echo "flip $(seth --to-dec 0x${data:196:64})" + echo "flipper 0x${data:218:40}" + echo "flip $(seth --to-dec 0x${data:258:64})" echo "tx: $tx"; echo "block: $block"; echo diff --git a/libexec/mcd/mcd-flips b/libexec/mcd/mcd-flips deleted file mode 100755 index 13d6d44..0000000 --- a/libexec/mcd/mcd-flips +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -### mcd-flips -- View flips and kick-off auctions -### Usage: mcd flips -### or: mcd flips kick -set -e -shopt -s extglob -case "$1" in - +([[:digit:]])) { - id=$(seth --to-word $(seth --to-hex $1)) - flip=$(seth call "${MCD_CAT?}" 'flips(uint256)(bytes32,address,uint256,uint256)' "$id") - ilk=${flip:0:64} - echo "ilk $(mcd --to-ascii $ilk)" - echo "urn 0x${flip:65:40}" - echo "ink $(mcd --to-wad ${flip:130:64})" - echo "tab $(mcd --to-rad ${flip:195:64})" - };; - kick) { - [ $# = 3 ] || mcd --fail "$0: Incorrect arguments" - id=$(seth --to-word $(seth --to-hex $2)) - rad=$(bc <<<"$3 * 10 ^ 45 / 1") - rad=$(seth --to-word $(seth --to-hex $rad)) - mcd flips-kick $id $rad - };; - *) { - mcd help flips - } -esac diff --git a/libexec/mcd/mcd-flips-kick b/libexec/mcd/mcd-flips-kick deleted file mode 100755 index 65790ae..0000000 --- a/libexec/mcd/mcd-flips-kick +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -e -p() { printf "%-3s %-50s %-10s\n" "$1" "$2" "$3"; } - -export ETH_GAS=${ETH_GAS:-250000} - -sig="flip(uint256,uint256)(uint256)" -tx=$(seth send --async "${MCD_CAT?}" $sig "$1" "$2") -echo >&2 -n "${0##*/}: Waiting for transaction receipt..." -block=$(SETH_TICK=true seth receipt "$tx" blockNumber) -block=$(seth --to-hex "$block") -echo >&2 - -sig="FlipKick(uint256,uint256)" -keccak=$(seth keccak "$(seth --from-ascii $sig)") -logs=$(seth rpc eth_getLogs -- \ - -n {} \ - -s "${MCD_CAT?}" -i address \ - -s "$block" -i fromBlock \ - -s "$block" -i toBlock \ - -n [] \ - -s "$keccak" -i append \ - -i topics \ - -i append | echo "[$(paste -sd , -)]") -data=$(echo "$logs" | jshon -a -e data -u) -hash=$(echo "$logs" | jshon -a -e transactionHash -u) - -if [ "$hash" == "$tx" ]; then - echo "$tx" - mcd flips $(seth --to-dec $1) - echo - echo "flip auction id: $(seth --to-dec ${data:(-64)})" -else - echo >&2 "${0##*/}: Transaction failed." - seth >&2 receipt "$tx" - exit 1 -fi diff --git a/libexec/mcd/mcd-test b/libexec/mcd/mcd-test index 19d51a6..80e7cbe 100755 --- a/libexec/mcd/mcd-test +++ b/libexec/mcd/mcd-test @@ -53,33 +53,33 @@ updatePrice() { # Tests #==================================================================== -testEthFrob() { - export MCD_ILK=ETH-A - mcd wrap 10 - testInc "gem join" "10" "gem balance vat" # Gem join - testInc "frob" "1 4" "gem balance ink" # Lock & draw - testDec "dai exit" "4" "dai balance vat" # Dai exit - testInc "dai join" "4" "dai balance vat" # Dai join - testDec "frob" "-1 -4" "gem balance ink" # Wipe & free - testDec "gem exit" "10" "gem balance vat" # Gem exit - mcd unwrap 10 -} -testEthFrob +# testEthFrob() { +# export MCD_ILK=ETH-A +# mcd wrap 10 +# testInc "gem join" "10" "gem balance vat" # Gem join +# testInc "frob" "1 4" "gem balance ink" # Lock & draw +# testDec "dai exit" "4" "dai balance vat" # Dai exit +# testInc "dai join" "4" "dai balance vat" # Dai join +# testDec "frob" "-1 -4" "gem balance ink" # Wipe & free +# testDec "gem exit" "10" "gem balance vat" # Gem exit +# mcd unwrap 10 +# } +# testEthFrob -testBite() { - export MCD_ILK=COL1-A - dink=10 - spot=$(mcd ilk spot); mat=$(mcd ilk mat) - dart=$(echo "($dink * $spot) - 1" | bc -l) - mcd gem join $dink - mcd frob $dink $dart - ink=$(mcd gem balance ink) - updatePrice $(echo "($spot * $mat) * 0.9" | bc -l) # unsafe - mcd --urn=$ETH_FROM bite - updatePrice $(echo "($spot * $mat) * 1" | bc -l) # safe - assertBalanceChanged $ink 0 $ink -} -testBite +# testBite() { +# export MCD_ILK=COL1-A +# dink=10 +# spot=$(mcd ilk spot); mat=$(mcd ilk mat) +# dart=$(echo "($dink * $spot) - 1" | bc -l) +# mcd gem join $dink +# mcd frob $dink $dart +# ink=$(mcd gem balance ink) +# updatePrice $(echo "($spot * $mat) * 0.9" | bc -l) # unsafe +# mcd --urn=$ETH_FROM bite +# updatePrice $(echo "($spot * $mat) * 1" | bc -l) # safe +# assertBalanceChanged $ink 0 $ink +# } +# testBite testCdpOpen() { cdp=$(mcd cdp open)