Skip to content

Instantly share code, notes, and snippets.

@cryptoscopia
cryptoscopia / pwoh_graph.py
Created January 29, 2018 09:31
Parse CSV exports of Etherscan transactions into one graph-friendly CSV file
#!/usr/bin/env python
from __future__ import print_function
import argparse
from collections import OrderedDict
import csv
from datetime import datetime, timedelta
from decimal import Decimal
parser = argparse.ArgumentParser()

Keybase proof

I hereby claim:

  • I am cryptoscopia on github.
  • I am cryptoscopia (https://keybase.io/cryptoscopia) on keybase.
  • I have a public key ASBGZs2T8s_oxzwUgg_oECOFm8Ypt4WPTKdNlrmRbShKywo

To claim this, I am signing this object:

@cryptoscopia
cryptoscopia / btcaud_hourly.py
Created July 4, 2018 16:30
A script to fetch hourly historic price data for the last financial year for BTC/AUD, using the CryptoCompare API and save it as CSV.
from __future__ import print_function
import requests
data = []
timestamp = 1530367200 # 2018-07-01 00:00 AEST
for t in range(1530367200, 1530367200-365*24*60*60, -2001*60*60):
data = requests.get(
'https://min-api.cryptocompare.com/data/histohour?fsym=BTC&tsym=AUD&toTs=%s&limit=%s' \
% (t, min(365*24-len(data), 2000))
).json()['Data'] + data
@cryptoscopia
cryptoscopia / pwoh_graph_api.py
Created January 29, 2018 21:44
Parse Etherscan API transaction lists into a CSV of cumulative incoming, outgoing, and total values
#!/usr/bin/env python
from __future__ import print_function
import argparse
from collections import OrderedDict
from datetime import datetime, timedelta
from decimal import Decimal
import json
parser = argparse.ArgumentParser()
@cryptoscopia
cryptoscopia / dydxFlashLoanTemplate.sol
Created October 21, 2020 06:42
A single-file simplest possible template for a contract that obtains a flash loan from dydx, does things, and pays it back.
// SPDX-License-Identifier: AGPL-3.0-or-later
// The ABI encoder is necessary, but older Solidity versions should work
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
// These definitions are taken from across multiple dydx contracts, and are
// limited to just the bare minimum necessary to make flash loans work.
library Types {
enum AssetDenomination { Wei, Par }