Skip to content

Instantly share code, notes, and snippets.

@godsflaw
Created July 28, 2019 20:58
Show Gist options
  • Save godsflaw/29e107e757b7a7ebdcaacd6a6ab6bcfd to your computer and use it in GitHub Desktop.
Save godsflaw/29e107e757b7a7ebdcaacd6a6ab6bcfd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
QUERY='{ allCups(condition: {deleted: false}, filter: {tab: {greaterThan: "0.0"}}, orderBy: ID_ASC) { nodes { id tab } } }'
curl -s \
-XPOST \
-H 'Content-Type:application/graphql' \
-d "${QUERY}" \
https://sai-mainnet.makerfoundation.com/v1 \
| python -m json.tool \
| fgrep '"tab"' \
| awk -F' "' '{ print $3}' \
| sed 's/"//' \
| awk '{ sum += sprintf("%f", $1) } END { printf "%.2f\n", sum/100 }'
@godsflaw
Copy link
Author

produces the following output:

% ./get-fee-owed.sh
2833183.83

At the time of writing, the value 2,833,183.83 is lower than, and accumulating slower than, those displayed on popular MakerDAO tools. This requires more debugging to understand the discrepancy. When querying single CDPs, the results are correct. Querying for deleted CDPs doesn't produce the correct number either. Aside from that the query is fairly permissive.

Anyway, the perfect is the enemy of the done. So, here is a leaping off point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment