{"id":25249992,"url":"https://github.com/bryanlabs/staking-rewards","last_synced_at":"2025-04-05T22:12:38.207Z","repository":{"id":115242730,"uuid":"477175246","full_name":"bryanlabs/staking-rewards","owner":"bryanlabs","description":"Gathers data from various public APIs to get USD Value for Accointing Export CSV rows","archived":false,"fork":false,"pushed_at":"2025-02-05T03:50:26.000Z","size":632,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T04:26:04.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bryanlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-02T21:26:48.000Z","updated_at":"2025-02-05T03:50:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"fecb6932-384d-4cf2-8014-ba319155fa2b","html_url":"https://github.com/bryanlabs/staking-rewards","commit_stats":null,"previous_names":["bryanlabs/staking-rewards"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlabs%2Fstaking-rewards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlabs%2Fstaking-rewards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlabs%2Fstaking-rewards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bryanlabs%2Fstaking-rewards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bryanlabs","download_url":"https://codeload.github.com/bryanlabs/staking-rewards/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406110,"owners_count":20933806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-12T03:51:57.505Z","updated_at":"2025-04-05T22:12:38.186Z","avatar_url":"https://github.com/bryanlabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cost-Calc Script\n\nRun this script on an Accointing Excel export file and it will reach out to [CoinGecko](https://www.coingecko.com/) to get the costs of symbols according to the following metrics:\n\n* Specific classifications such as `staked` or `airdrops`\n* Based on the date column for specific years\n\nIt will then output a new file with all the original rows except for a few differences:\n\n* A new column `usdValue`\n* For every row that matched the metric, this column will be filled out with the following formula: `\u003cSymbol cost on that date in USD\u003e * \u003cnumber of coins of that symbol\u003e = usdValue`\n\nAs a fallback option, if CoinGecko does not provide full time-range coverage for all Symbol + Date combinations, the script will reach out to Coinhall (a Terra price tracker). This will only work for missing Terra symbols.\n\n# Requirements\n\n* Python 3+\n* Python packages: The script requires some imports\n    * `requests` for reaching out to the CoinGecko API\n    * `openpyxl` for reading and writing Excel files.\n    * You can install these into your Python environment by running `python -m pip install -r requirements.txt`\n* A preconfigured CoinGecko Coins config JSON file\n    * Containing the following:\n        * A dictionary with keys of Symbols (as found in your Accointing export)\n        * The values of these keys must contain CoinGecko information relating to the CoinGecko API request for that symbol\n    * A preconfigured list already comes with the package, make sure to check that out to see the default configuration and make sure it matches up to your use-case\n    * The values must contain the ID used by CoinGecko for the corresponding symbol\n    * E.g.\n\n```\n{\n    \"DAI\": {\n        \"id\": \"dai\",\n        \"symbol\": \"dai\",\n        \"name\": \"Dai\"\n    },\n    \"ADA\": {\n        \"id\": \"cardano\",\n        \"symbol\": \"ada\",\n        \"name\": \"Cardano\"\n    },\n    \"ANC\": {\n        \"id\": \"anchor-protocol\",\n        \"symbol\": \"anc\",\n        \"name\": \"Anchor Protocol\"\n    },\n    ...\n}\n```\n\n* You can check and/or add new values to this config file by running the following command and analyzing the output `coingecko_coins.json` file. You would then add new Symbol/config pairs for any Symbol you want\n\n```\npython -c \"import json; import requests; print(json.dumps(requests.get('https://api.coingecko.com/api/v3/coins/list').json(), indent=4))\" \u003e coingecko_coins.json\n```\n\n* A CoinHall symbol config json file is required as well\n    * If using certain Terra coins, CoinGecko may not cover them. The code falls back on Coinhall if CoinGecko did not provide coverage\n    * Containing the following:\n        * A dictionary with keys of Symbols (as found in your Accointing export)\n        * The values of these keys must contain Coinhall information relating to the Coinhall API request for that symbol\n        * Coinhall tracks the symbol by Terra pair address, see the Coinhall implementation for details\n```\n#e.g.\n{\n    \"MINE\": {\n        \"id\": \"terra178jydtjvj4gw8earkgnqc80c3hrmqj4kw2welz\", #Symbol pair address\n        \"symbol\": \"mine\",\n        \"name\": \"Pylon Protocol\"\n    },\n    \"PSI\": {\n        \"id\": \"terra163pkeeuwxzr0yhndf8xd2jprm9hrtk59xf7nqf\",\n        \"symbol\": \"psi\",\n        \"name\": \"Nexus Protocol\"\n    },\n    \"LOOP\": {\n        \"id\": \"terra106a00unep7pvwvcck4wylt4fffjhgkf9a0u6eu\",\n        \"symbol\": \"loop\",\n        \"name\": \"LOOP Finance\"\n    },\n    ...\n}\n```\n\n# How to run\n\nThe script takes a few configuration options, some with defaults, some without. You can see all the options by running `python cost_calc.py -h`\n\nThe required options are as follows:\n\n* `-i` The input Excel file path to process\n* `-o` The output Excel file path to create\n* `-cgstoid` The configuration JSON file path for the CoinGecko symbols to ids configuration\n* `-chstoid` The configuration JSON file path for the Coinhall symbols to ids configuration\n\n\nSo, to run you would do something like this:\n\n`python staking-rewards.py -i path/to/input.xlsx -o path/to/output.xlsx -cgstoid path/to/coingecko/config.json -chstoid path/to/coinhall/config.json`\n\nYou will then need to examine the output file to confirm the process worked after it has finished.\n\n# Gotchas\n\nThe script is 100% reliant on the CoinGecko API. This comes with 2 gotchas:\n\n1. CoinGecko stores data on their servers for every coin. **If CoinGecko does not have data for a specific symbol on a specific date, this script will NOT be able to get the cost.** When this happens, the script will output the Excel lines so you can fill in the gaps where needed.\n2. If you forget to put a symbol config value in your `config.json` file, the script will **NOT** be able to fill in the cost for that symbol. Symbol names are not unique, so these cannot be reliad on to find the correct cost from CoinGecko.\n3. CoinGecko has a rate-limit and there is no current way to provide and API key if you pay for a higher rate-limit. You will have to wait at least a few minutes (depending on how many transactions are being processed)\n\nThe script has a fallback API request structure that will reach out to Coinhall for symbols that do not have coverage in CoinGecko. This comes 2 with gotchas:\n\n1. Coinhall is Terra specific, it will not provide coverage outside of Terra coins\n2. Coinhall tracks price in quotes by uusd and pair address - Terra provides pair addresses that Coinhall uses to track Open/High/Low/Close values.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanlabs%2Fstaking-rewards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbryanlabs%2Fstaking-rewards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbryanlabs%2Fstaking-rewards/lists"}