Skip to content

Instantly share code, notes, and snippets.

@hbarcelos
Created May 19, 2022 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbarcelos/f8da98a0e5104d059aca57cfaed7fbfd to your computer and use it in GitHub Desktop.
Save hbarcelos/f8da98a0e5104d059aca57cfaed7fbfd to your computer and use it in GitHub Desktop.
MCD: Add new ilk
#!/bin/env bash
set -euo pipefail
[ -z "$1" ] && {
cat <<USAGE
Usage:
$0 <ilk> [--estimate]
USAGE
exit 1
}
ILK="$1"
ILK_ENCODED=$(seth --to-bytes32 $(seth --from-ascii "$ILK"))
action='send'
[[ "${2:-}" == "--estimate" ]] && action=estimate
# Replace - with _
ILK_PREFIX=${ILK/-/_}
# Deploy the Join contract
# JOIN=$(seth "$action" $JOIN_FAB "newGemJoin(address owner, bytes32 ilk, address gem)" \
# $MCD_PAUSE_PROXY $ILK_ENCODED $WSTETH)
# Deploy the Clip contract
CLIP=$(seth "$action" $CLIP_FAB "newClip(address owner, address vat, address spotter, address dog, bytes32 ilk)" \
$MCD_PAUSE_PROXY $MCD_VAT $MCD_SPOT $MCD_DOG $ILK_ENCODED)
# Deploy the ClipCalc/Abacus contract
# CLIP_CALC=$(seth "$action" $CALC_FAB "newStairstepExponentialDecrease(address owner)" \
# $MCD_PAUSE_PROXY)
if [[ "$action" == 'send' ]]; then
cat <<ENV
MCD_JOIN_${ILK_PREFIX}=${JOIN:-}
MCD_CLIP_${ILK_PREFIX}=${CLIP:-}
MCD_CLIP_CALC_${ILK_PREFIX}=${CLIP_CALC:-}
ENV
else
gas_price=$(seth gas-price)
join_cost=$(bc <<< "${JOIN:=0}*${gas_price}")
clip_cost=$(bc <<< "${CLIP:=0}*${gas_price}")
clip_calc_cost=$(bc <<< "${CLIP_CALC:=0}*${gas_price}")
cat <<ESTIMATE
GAS:
MCD_JOIN_${ILK_PREFIX}=${JOIN:=0}
MCD_CLIP_${ILK_PREFIX}=${CLIP:=0}
MCD_CLIP_CALC_${ILK_PREFIX}=${CLIP_CALC:=0}
TOTAL=$(bc <<< "${JOIN} + ${CLIP} + ${CLIP_CALC}")
GAS PRICE:
$(seth --from-wei $gas_price gwei) gwei
COST:
MCD_JOIN_${ILK_PREFIX}=$(seth --from-wei $join_cost) ETH
MCD_CLIP_${ILK_PREFIX}=$(seth --from-wei $clip_cost) ETH
MCD_CLIP_CALC_${ILK_PREFIX}=$(seth --from-wei $clip_calc_cost) ETH
TOTAL=$(seth --from-wei $(bc <<< "${join_cost} + ${clip_cost} + ${clip_calc_cost}")) ETH
ESTIMATE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment