This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmcd-flips-cmd
executable file
·43 lines (40 loc) · 1.62 KB
/
mcd-flips-cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -e
FLIPPER=$1; shift
ID=$(seth --to-word $(seth --to-hex $1)); shift
p() { printf "%-4s %-52s %-10s\n" "$1" "$2" "$3"; }
case $1 in
tick) {
(set -x; seth send "$FLIPPER" 'tick(uint256)' "$ID")
};;
tend) {
[ $# = 3 ] || mcd --fail "mcd-flips: Incorrect arguments"
mcd --vat-hope "$FLIPPER"
lot=$(seth --to-uint256 "$(seth --to-wei "$2" eth)") # [wad]
bid=$(seth --to-uint256 "$(bc <<<"$3 * 10 ^ 45 / 1")") # [rad]
seth send $FLIPPER 'tend(uint id, uint lot, uint bid)' "$ID" "$lot" "$bid"
[[ $SETH_ASYNC != yes ]] && mcd flips "$(seth --to-dec "$ID")"
};;
dent) {
[ $# = 3 ] || mcd --fail "mcd-flips: Incorrect arguments"
mcd --vat-hope "$FLIPPER"
lot=$(seth --to-uint256 "$(seth --to-wei "$2" eth)") # [wad]
bid=$(seth --to-uint256 "$(bc <<<"$3 * 10 ^ 45 / 1")") # [rad]
seth send "$FLIPPER" 'dent(uint id, uint lot, uint bid)' "$ID" "$lot" "$bid"
[[ $SETH_ASYNC != yes ]] && mcd flips "$(seth --to-dec "$ID")"
};;
deal) {
seth send "$FLIPPER" 'deal(uint256)' "$ID"
};;
*) {
bid=$(seth call "$FLIPPER" 'bids(uint)' "$ID")
p "bid" "$(mcd --to-rad "${bid:2:64}")" "Last bid amount"
p "lot" "$(mcd --to-wad "${bid:66:64}")" "Lot amount"
p "guy" "0x${bid:154:40}" "Highest bidder"
p "tic" "$(seth --to-dec "${bid:194:64}")" "Bid expiry"
p "end" "$(seth --to-dec "${bid:258:64}")" "Auction end"
p "urn" "0x${bid:346:40}" "Gem surplus recipient"
p "gal" "0x${bid:410:40}" "Dai recipient (vow)"
p "tab" "$(mcd --to-rad "${bid:450:64}")" "Debt to recover"
};;
esac