Git Product home page Git Product logo

opencryptotax's Introduction

OpenCryptoTax

Free, open source software to potentially help crypto users when preparing their taxes.

Absolutely NO guarantee of accuracy is included with this software or documentation.

Absolutely NO Tax or financial advice is included in this software or documentation.

Absolutely NO information that this software gives as examples of tax calculation to help comply with US or any other country's tax laws is shall be considered tax or financial advice whatsoever.

TLDR: Discuss everything with your accountant and don't trust this software to do anything.

USE AT YOUR OWN RISK!

Overview

This repository is a custom software solution used to help track/document/define relevant parameters related to taxes owed on assets such as cryptocurrency.

Assumptions

FIFO rules are used. Details such as properly including fees in basis prices, "selling" assets used to pay fees (e.g. pay gas fees in ETH) are all intended to be properly followed.

Getting Started

Environment Variables

Web3 connections are used to pull transaction fee data in this software. A .env file must be created; use .env.example as a template. Any HTTP RPC provider may be used (GetBlock.io free-tier should suffice). Currently, ETH and BSC chains are able to be used by this software.

Populate input csv file

input_RevA.csv must be filled out. Each row represents a "transaction", with the understanding that some "transactions" may span multiple blockchain transactions (e.g. call approve on an ERC20 token, then swap it, all can be booked as a single "transaction").

Individual rows may include Sell or Buy assets, and define fees. Details on a few non-intuitive columns:

  • [Buy/Sell]SpotPrice/TotalUSD - Either spot price of asset or total cost in USD must be populated. Both should not be populated, but will prefer spot-price if both exist. If there is a buy and sell on line, one Buy/Sell TotalUSD may be set to a special value of equal to indicate totals of buy and sell should match (preventing double-entry of identical values)
  • IsOrdinaryIncome - Set to true or yes if Buy asset is ordinary income. This will treat the value of the received asset (in USD) as ordinary income, and track the asset as "bought" at the appropriate cost basis (Spot Price + any fees).
  • *SpotPrice - Price in USD of qty 1.00 of asset
  • *BookFeeWith - (may be blank if only either a buy or sell) Either blank, buy, sell, or gas. If gas, must be no buy or sell, and will NOT include the fee in any asset cost basis or sell fee. Will simply treat as a fee-less sale of ETH for USD, since that is all some transactions do (i.e. failed bids, recalled bids, etc.).
  • FeeChain[N] - Chain of tx to get fee info from web, options are ETH, BSC
  • FeeTx[N] - tx hash to get fee info from web
  • AuxFeeAsset - Auxiliary fee paid in some asset defined here
  • FeeUSD - Any fees paid in USD

Web3/Subgraph helper Utils

Import Swap Transactions

python import_swap_transactions.py

A simple import helper util may help with populating the input.csv file. Currently, running import_transactions.py can automatically import (i.e. format) sushiswap Swap ETH For Exact Tokens and Swap Exact Tokens For ETH calls. input/utils/import_swap_txs.example.csv provides an example formatted list of transactions to import.

The user must create a file input/users/import_swap_txs.csv to be loaded when running the command.

Import (Summarize) CryptoPunk Transactions

python import_punk_transactions.py

A simple helper that shows more information about transactions on the CryptoPunks market for method calls to:

  • Offer Punk For Sale
    • Exports which punk ID and asking price in ETH
  • Offer Punk For Sale To Address
    • Exports which punk ID, asking price in ETH, and address offered to

input/utils/import_punk_txs.example.csv provides an example formatted list of transactions to import.

The user must create a file input/users/import_punk_txs.csv to be loaded when running the command.

Validate input file (generate valid input.csv)

To generate a checked input file ./input/input_valid.csv:

python generate_valid_input_file.py ./input/<unchecked_input.[csv|xlsx] <xlsx tab name>
// e.g.
python generate_valid_input_file.py input/input.xlsx input

tab name not required

currently, input xlsx files are being used, csv behavior mostly unchecked

Once you have what you think is a valid input.csv/xlsx file, this utility:

  • validates the input file
    • expected values are correct formats, qty/spotprice/totals match within tolerance
  • generates a new input.csv file that contains all values filled out:
    • shorthand format such as equal or whitespace in spot price/total filled in

Note: some items are still missed by the validator, but should be picked up by the code when generating a TokenTax summary XD

Generate TokenTax Summary

python generate_tokentax_summary.py ./input/input_valid.csv

This command will turn a valid input file into a CSV compatible with TokenTax.

TokenTax CSV specs are defined here: https://help.tokentax.co/en/articles/1707630-create-a-manual-csv-report-of-your-transactions

This is the file you would want to send to your accountant, or use with TokenTax directly.

The following is a list of likely "Type" categorization based on TokenTax's spec. NONE OF THIS IS TAX ADVICE OR FINANCIAL ADVICE

Condition / situation TokenTax Type
isOrdinaryIncome Income [0]
mining (business) Trade [1]
swap/buy/sell Trade
gas (to be included in basis) Totals listed in FeeAmount and FeeCurrency [2] [3]
gas-only (not in any basis or trade fee) Spend [4]
gift (from me to someone else) Gift [5]
gift (to me from someone else) Trade [6]

[0] includes events such as airdrops, hard forks, hobby mining, staking rewards, claimable LP rewards

[1] business income tracked elsewhere, but personally treat as buying mined currency with USD

[2] if multiple fee currencies (e.g. ETH and USD), include USD in basis, making sure to track any asset sales used to pay for gas (e.g. pay ethereum gas fees in ETH must be tracked as sale of ETH)

[3] any relevant tx_hash(es) should be listed in comment json { "feeTxHashes": string[] }

[4] spend amount = 0, track gas fees in FeeAmount & FeeCurrency. if multiple currencies, require to be broken up.

[5] leave buy blank, use sell fields, set exchange as "Gift"

[6] my understanding is that Buy would be gift-giver's cost basis :)

Generate Current Balances from TokenTax summary

A summary of current balances of every non-zero asset is automatically generated when a TokenTax summary is generated.

Possible Future Improvements

  • (currently recommend using TokenTax for this via csv upload and paying a fee) Write code that tracks & outputs tax liability for a given year, given tax brackets for that year (not required, but helps quarterly estimates)

Other

Helpful Links

The following links references different endpoints/dependencies related to this software.

Potentially Helpful Tax Info/References

opencryptotax's People

Contributors

ryley-tokensign avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.