-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpurge
executable file
·48 lines (40 loc) · 1.67 KB
/
purge
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
44
45
46
47
48
# Copyright (C) 2019 - 2020 Maker Ecosystem Growth Holdings, INC.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#!/usr/bin/env bash
set -ex
export ETH_GAS=${ETH_GAS:-"500000"}
export ETH_FROM=${ETH_FROM:-$(seth rpc eth_coinbase)}
NETWORK=$(seth chain)
# shellcheck source=/dev/null
. ./"$NETWORK"-pairs
ETH_NONCE=$(seth nonce "$ETH_FROM")
remove_offers () {
OFFER_ID="$1"
while [ "$(seth --to-dec "$OFFER_ID")" -gt 0 ]; do
NEXT_OFFER_ID=$(seth call "$OTC" "getWorseOffer(uint256)(uint256)" "$OFFER_ID")
echo "Deleting offer $(seth --to-dec "$OFFER_ID")..."
ETH_NONCE=$((ETH_NONCE)) seth send "$OTC" "cancel(uint256)" "$OFFER_ID" --async
ETH_NONCE=$((ETH_NONCE + 1))
OFFER_ID="$NEXT_OFFER_ID"
done
}
for PAIR in $ALL_PAIRS; do
ADDR1=$(echo "$PAIR" | cut -f1 -d-)
ADDR2=$(echo "$PAIR" | cut -f2 -d-)
OFFER_ID=$(seth call "$OTC" "getBestOffer(address,address)(uint256)" "$ADDR1" "$ADDR2")
remove_offers "$OFFER_ID"
OFFER_ID=$(seth call "$OTC" "getBestOffer(address,address)(uint256)" "$ADDR2" "$ADDR1")
remove_offers "$OFFER_ID"
done