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

Fix: cast spell script #247

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/cast-dssspell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ MCD_IOU=$(cast call "$CHANGELOG" 'getAddress(bytes32)(address)' "$(cast --to-byt
### Data
DESIRED_HAT_APPROVALS=$(cast --to-wei 100000 ETH)
hat=$(cast call "$MCD_ADM" 'hat()(address)')
approvals=$(cast call "$MCD_ADM" 'approvals(address)(uint256)' "$hat")
deposits=$(cast call "$MCD_ADM" 'deposits(address)(uint256)' "$ETH_FROM")
approvals=$(cast call "$MCD_ADM" 'approvals(address)' "$hat" | cast --to-dec)
deposits=$(cast call "$MCD_ADM" 'deposits(address)' "$ETH_FROM" | cast --to-dec)

ETH_NONCE=$(cast nonce "$ETH_FROM")

Expand All @@ -39,12 +39,12 @@ else

if [[ "$(echo "$deposits < $target" | bc)" == 1 ]]; then
lockAmt=$(echo "$target - $deposits" | bc)
[[ "$(echo "$(cast call "$MCD_GOV" 'balanceOf(address)(uint256)' "$ETH_FROM") >= $lockAmt" | bc)" == 1 ]] || { echo "$ETH_FROM: Insufficient MKR Balance"; exit 1; }
[[ "$(echo "$(cast call "$MCD_GOV" 'balanceOf(address)' "$ETH_FROM" | cast --to-dec) >= $lockAmt" | bc)" == 1 ]] || { echo "$ETH_FROM: Insufficient MKR Balance"; exit 1; }

castSend "$MCD_GOV" 'approve(address,uint256)' "$MCD_ADM" "$lockAmt"
castSend "$MCD_ADM" 'lock(uint256)' "$lockAmt"

deposits=$(cast call "$MCD_ADM" 'deposits(address)(uint256)' "$ETH_FROM")
deposits=$(cast call "$MCD_ADM" 'deposits(address)' "$ETH_FROM" | cast --to-dec)
fi

castSend "$MCD_ADM" 'vote(address[] memory)' ["$1"]
Expand All @@ -59,7 +59,7 @@ else

if [[ "$(echo "$deposits > $DESIRED_HAT_APPROVALS" | bc)" == 1 ]]; then
freeAmt=$(echo "$deposits - $DESIRED_HAT_APPROVALS" | bc)
[[ "$(echo "$(cast call "$MCD_IOU" 'balanceOf(address)(uint256)' "$ETH_FROM") >= $freeAmt" | bc)" == 1 ]] || { echo "$ETH_FROM: Insufficient IOU Balance"; exit 1; }
[[ "$(echo "$(cast call "$MCD_IOU" 'balanceOf(address)' "$ETH_FROM" | cast --to-dec) >= $freeAmt" | bc)" == 1 ]] || { echo "$ETH_FROM: Insufficient IOU Balance"; exit 1; }
castSend "$MCD_IOU" 'approve(address,uint256)' "$MCD_ADM" "$freeAmt"
castSend "$MCD_ADM" 'free(uint256)' "$freeAmt"
fi
Expand Down
Loading