-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hodgerpodger
committed
Dec 9, 2021
1 parent
9832908
commit 08b2e2f
Showing
77 changed files
with
35,393 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
__pycache__/* | ||
*/__pycache__/* | ||
*/*/__pycache__/* | ||
.idea/* | ||
sol/data_staking_rewards/*.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021, stake.tax | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
|
||
# staketaxcsv | ||
python repo to create blockchain CSVs | ||
|
||
A python repo to create CSVs for Terra (LUNA), Solana (SOL), and Cosmos (ATOM). | ||
|
||
# Install | ||
|
||
1. Install python 3.9.9 ([one way](README_reference.md#installing-python-39-on-macos)) | ||
2. Install pip packages ```pip3 install -r requirements.txt``` | ||
3. Edit (~/.bashrc, ~/.zshrc, shell equivalent) so that it loads sample.env in shell: | ||
``` | ||
set -o allexport | ||
source <PATH_TO_SAMPLE_ENV_HERE>/sample.env | ||
set +o allexport | ||
``` | ||
|
||
4. For ATOM only, install `gaiad` | ||
- https://hub.cosmos.network/main/gaia-tutorials/installation.html | ||
|
||
# Usage | ||
|
||
* Same arguments apply for report_terra.py (LUNA), report_sol.py (SOL), report_atom.py (ATOM): | ||
``` | ||
# Create default CSV | ||
python3 report_terra.py <wallet_address> | ||
# Create all CSV formats (i.e. koinly, cointracking, etc.) | ||
python3 report_terra.py <wallet_address> --format all | ||
# Show CSV result for single transaction (great for development/debugging) | ||
python3 report_terra.py <wallet_address> --txid <txid> | ||
``` | ||
# Reference | ||
* See [README_reference](README_reference.md) for more notes. | ||
* [Ideal Configuration](README_reference.md#ideal-configuration) | ||
* [RPC Node Settings](README_reference.md#rpc-node-settings) | ||
* [DB Cache](README_reference.md#db-cache) | ||
* [Installing python 3.9.9 on MacOS](README_reference.md#installing-python-39-on-macos) | ||
* [Unit Tests](README_reference.md#unit-tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
# Reference | ||
|
||
* Random notes, hopefully helpful on occasion. Probably not helpful on first look. | ||
|
||
## Ideal Configuration | ||
|
||
Default code was made to work out of the box. These are changes that require manual | ||
actions. They improve reliability (RPC Node settings) or speed (DB Cache) when compared to | ||
default version. | ||
|
||
### RPC Node settings | ||
|
||
* Default `sample.env` points to public RPC nodes. This generally works, up to a point. | ||
* Edit/uncomment `sample.env` to change to point to more reliable private RPC node(s). | ||
* Examples for private RPC nodes (Figment, Quicknode) are included. | ||
|
||
### DB Cache | ||
|
||
Use of a database for caching is ideal to speed up certain RPC queries (especially SOL). Here is | ||
the script usage to use caching: | ||
|
||
``` | ||
# --cache flag requires implementation of Cache class (common/cache.py) | ||
python3 report_terra.py <wallet_address> --cache | ||
``` | ||
|
||
To enable --cache, you must configure an aws connection for the boto3 code found in common/Cache.py. | ||
* One method: `aws configure` | ||
* See here to install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html | ||
* See here to use `aws configure`: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html | ||
|
||
Alternatively, you may implement your own Cache class (common/cache.py). | ||
|
||
## Installing python 3.9 on MacOS | ||
|
||
* Personal method--google is probably better | ||
|
||
``` | ||
# Install brew (see https://brew.sh/) | ||
# python 3.9.9 | ||
brew install openssl readline sqlite3 xz zlib | ||
pyenv install 3.9.9 | ||
# use virtualenv | ||
brew install virtualenv | ||
virtualenv -p .pyenv/versions/3.9.9/bin/python3.9 env | ||
source env/bin/activate | ||
# install pip packages (same as README.md) | ||
pip3 install -r requirements.txt | ||
``` | ||
## Unit Tests | ||
You may notice a lack of unit tests in this codebase. Though tests exist, I omitted them because they rely on extensive | ||
use of real world wallet data. For the sake of all users' privacy, I do not include these tests. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
import logging | ||
import time | ||
from atom.config_atom import localconfig | ||
|
||
SECONDS_PER_PAGE = 15.0 | ||
|
||
|
||
class ProgressAtom(): | ||
|
||
def __init__(self): | ||
self.pages = [] | ||
|
||
def set_estimate(self, pages): | ||
self.pages = pages | ||
|
||
def report_message(self, message): | ||
if localconfig.job: | ||
localconfig.job.set_message(message) | ||
logging.info({"message": message}) | ||
|
||
def report(self, page, message): | ||
pages_left = len(self.pages) - self.pages.index(page) | ||
|
||
# Estimate timestamp job finishes | ||
seconds_left = pages_left * SECONDS_PER_PAGE | ||
time_complete = int(time.time() + seconds_left) | ||
|
||
# Write to db | ||
if localconfig.job: | ||
localconfig.job.set_in_progress(message, time_complete) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
class localconfig: | ||
|
||
job = None | ||
debug = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
EXCHANGE_COSMOS_BLOCKCHAIN = "cosmos_blockchain" | ||
CUR_ATOM = "ATOM" | ||
MILLION = 1000000.0 | ||
CURRENCIES = { | ||
"14F9BC3E44B8A9C1BE1FB08980FAB87034C9905EF17CF2F5008FC085218811CC": "OSMO" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
from common.Exporter import (TX_TYPE_STAKING) | ||
from common.make_tx import _make_tx_received, make_transfer_out_tx, make_transfer_in_tx | ||
from atom.constants import CUR_ATOM | ||
|
||
|
||
def make_reward_tx(txinfo, reward): | ||
return _make_tx_received(txinfo, reward, CUR_ATOM, TX_TYPE_STAKING) | ||
|
||
|
||
def make_transfer_receive_tx(txinfo, received_amount, received_currency=None): | ||
if not received_currency: | ||
received_currency = CUR_ATOM if txinfo.fee else "" | ||
|
||
return make_transfer_in_tx(txinfo, received_amount, received_currency) | ||
|
||
|
||
def make_transfer_send_tx(txinfo, sent_amount, sent_currency=None): | ||
if not sent_currency: | ||
sent_currency = CUR_ATOM if txinfo.fee else "" | ||
|
||
return make_transfer_out_tx(txinfo, sent_amount, sent_currency, None) |
Oops, something went wrong.