Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
support partial bites
Browse files Browse the repository at this point in the history
  • Loading branch information
desaperados committed May 19, 2019
1 parent 67e70f8 commit 0114c6f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 99 deletions.
15 changes: 8 additions & 7 deletions libexec/mcd/mcd-bite
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {} \
Expand All @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions libexec/mcd/mcd-bites
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
### mcd-bites -- Recent bites
### Usage: mcd bites [-B <block>] [--ilk=<id>] [--urn=<address>]
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")
Expand All @@ -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
Expand Down
27 changes: 0 additions & 27 deletions libexec/mcd/mcd-flips

This file was deleted.

37 changes: 0 additions & 37 deletions libexec/mcd/mcd-flips-kick

This file was deleted.

52 changes: 26 additions & 26 deletions libexec/mcd/mcd-test
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0114c6f

Please sign in to comment.