near/bounties

NEAR staking rewards tax tracker [$2000 in NEAR]

Closed this issue · 34 comments

Description

An open source web-hosted UI where people can track their staking rewards and other relevant tax information.

Context

Community members who stake usually have tax obligations based on the distribution of their rewards, so it is very important for tax season and useful in general to be able to see the income and tax implications of staking.

One dev hacked together a one-off tool to pull up all the staking rewards from the NF but it’s hard-coded with all the NF’s accounts and staking pools. It can be a start.

Acceptance Criteria

  • Input user accounts and it auto-detects the associated staking pools and rewards
  • pulls in Coinmarketcap and/or other feeds for historical daily data to match against and provide daily income information in USD or other currency equivalents
  • Is open source so people who don't want to share sensitive de-anonymizing info with a server can run it locally
  • Has logical aggregations like sums over monthly and annual time periods
  • Handles gracefully staking and unstaking transactions (so they don't look like staking rewards)

Nice to haves:

  • Charting

Bounty

$2000 USD equivalent in NEAR

I'd like to complete this bounty, Is there any formula, given the current stake of an ccount_id and current time, to calculate the rewards?

frol commented

@matteopozzadev there is no formula, you need to go over each epoch and query the delegated balance for the given account from the staking pool(s), and display the difference between the value from a previous epoch (a positive difference can be either the reward or extra deposit, ideally, we want to distinguish that, but in the meanwhile, we can live without this)

frol commented

Use https://archival-rpc.mainnet.near.org RPC server to be able to query the historical data, but make sure to handle potential errors in the responses (and retry if that is possible)

@matteopozzadev it's yours! Please @ mention me when it's done with the PR/repo associated.

Hello there. @eriktrautman If this isn't assigned yet; I would like to work on it. Also @frol the link https://archival-rpc.mainnet.near.org seems to be offline

@iamochuko The node is online, just use the status endpoint instead to check: https://archival-rpc.mainnet.near.org/status

@chefsale thanks.

Alright. I'll do so.

@iamochuko can you provide a timeline on your side?

@ilblackdragon In 48 hrs I'll make a pull request. While I think the api as specified in the docs was well simplified; I had a some challenges on collating the the required info. Though, as of now; I've a hold of it.

@ilblackdragon Hello; while I am not able to get the specifics to work together at the moment, I want to meet up with the 48hrs I set off two days back. Kindly find a link to the repo at https://github.com/iamochuko/near-staking-rewards-tax-tracker

Am hoping if someone could find it useful; then he/she can continue to develop on it. Meanwhile; I would do the same at my timing (as a personal task, just to make sure I get it working)

frol commented

I have learned that https://near-staking.com has received the functionality we describe in this bounty. You just enter the account id on the main page, and then click "View Account", and you will get to a page like this (took a random account that delegates tokens): https://near-staking.com/user/fcff408e50466e10d3c5eed46b9edcd1f3fff9a2594530c68eba4d1a14efd629

image

They are now improving the accuracy even further since now it (just like my script) relies on the ping calls to the staking pool, and if those were missing for a few epochs, the rewards "accumulate", and will only get observed when ping happens, so if there were no pings, it would appear like there were no rewards, but that is not the case.

@eriktrautman What should we do with this bounty given near-staking.com support?

@frol that's a good start but doesn't fulfill all the acceptance criteria. If you know who's running the site, you can definitely refer them to the bounty and if they handle unstaking more gracefully (I see negative numbers...), are open source, and have some basic aggregations over month and annual periods they can claim it.

We have releases a version with staking reward calculations, it is still under testing, but can be viewed here https://near-staking.com/user/your_account.near

The servers side is an open source and on GH https://github.com/DenysOf/near-staking/, we push the changes once it is QA-tested, but UI is a licensed component, and can't be pushed freely. We have it in the roadmap to remove licensed components by Summer, then it will be completely open-source.

Meanwhile, server side should be enough to fork and replicate.

The server side code is pushed to the GitHub, https://github.com/DenysOf/near-staking, which includes code to cache indexer data to the local mongo DB, rewards validator matching, etc.

Hey @eriktrautman, is this bounty completed? If so, who needs to be paid?

Hi @AngelBlock or @DenysOf, can you point @eriktrautman to the aggregations in the UI? It would be great to get you paid once everything checks out!

@cameron-NEAR @eriktrautman
Hi guys, The current UI we use on the website will not allow for any data manipulation (its basically a datatable), I'm working on the workaround to provide the aggregations as a separate table, but currently held up by other projects. It will take a couple of weeks.

Meanwhile, CSV export is available and its very easy for user to do any aggregations on excel, until I do the update.

Hey @DenysOf, it's great to hear that CSV export is available! How is everything else coming together?

Let me know if you're running into any problems and I'll do what I can to unblock them!

Hey @cameron-NEAR. We have a complete UI revamp scheduled to start by the end of May (that also make near-staking an open source), which allows to customise the data table and implement the aggregations. Should be completed by mid June.

@cameron-NEAR I'm removing the paid components, and it will be open-source in a few weeks, also looking at the aggregation and charts, should be all finished by no later the first week of July, I hope.

Fantastic news @DenysOf! Keep up the great work and let me know when you're done 🙌

did this ever get resolved?

@rencryptofish - it is being worked on by @DenysOf

cool, just wanted to mention that sometimes just showing the balance of an account_id from the staking pool's perspective might be confusing if the account_id also retains a liquid balance, would be good to include those as well if possible

@cameron-NEAR @eriktrautman
The aggregation is finished and code is on the GH, open-source. https://github.com/Lastblock-Limited/near-staking
Hope this helps.
please view example here: https://near-staking.com/user/<your_user_account>.near

cool, just wanted to mention that sometimes just showing the balance of an account_id from the staking pool's perspective might be confusing if the account_id also retains a liquid balance, would be good to include those as well if possible

This will be included in the coming releases. The recent release was a very big change and require some time to settle and some bug fixed, if any.

Hey @DenysOf! You did an amazing job and I'd like to get you paid ASAP. Can you drop your Telegram below?

Hey @DenysOf! You did an amazing job and I'd like to get you paid ASAP. Can you drop your Telegram below?

Thanks, I'll ping you on the telegram.

I'm assuming this done at this point. Closing.