near / bounties

Specs for technical and non-technical work that earns NEAR tokens
https://devgovgigs.near.social
73 stars 8 forks source link

NEAR staking rewards tax tracker [$2000 in NEAR] #41

Closed eriktrautman closed 2 years ago

eriktrautman commented 3 years ago

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

Nice to haves:

Bounty

$2000 USD equivalent in NEAR

matteopozzadev commented 3 years ago

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 3 years ago

@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 3 years ago

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)

behaviary commented 3 years ago

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

amochuko commented 3 years ago

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

chefsale commented 3 years ago

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

amochuko commented 3 years ago

@chefsale thanks.

eriktrautman commented 3 years ago

I have not yet seen a submission from anyone so dive in!

On Sun, Mar 7, 2021 at 2:34 AM awhe ochuko notifications@github.com wrote:

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

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/near/bounties/issues/41#issuecomment-792147860, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWW5HUGMVUA6DYW2Q24BULTCLJZ3ANCNFSM4XMVDLMA .

-- — Erik S. Trautman CEO, NEAR Foundation https://www.nearprotocol.com

amochuko commented 3 years ago

Alright. I'll do so.

ilblackdragon commented 3 years ago

@iamochuko can you provide a timeline on your side?

amochuko commented 3 years ago

@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.

amochuko commented 3 years ago

@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 3 years ago

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?

eriktrautman commented 3 years ago

@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.

AngelBlock commented 3 years ago

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.

eriktrautman commented 3 years ago

Great, just drop in here when you have the aggregations finished and we'll close it out. Those are important so people can easily select eg. 2020 tax year and just receive the correct information about the volume-weighted average pricing they received so they can pay their taxes properly.

On Wed, Mar 24, 2021 at 6:53 PM AngelBlock @.***> wrote:

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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/near/bounties/issues/41#issuecomment-806035448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWW5HX2OT2PLPRKSJYIKNLTFIRI5ANCNFSM4XMVDLMA .

DenysOf commented 3 years ago

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.

cameron-NEAR commented 3 years ago

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

eriktrautman commented 3 years ago

I'm not seeing the aggregations (eg for selecting "2020" and providing sensible averages+sums) in the UI. Am I missing something?

On Fri, Apr 2, 2021 at 12:50 PM Cameron Dennis @.***> wrote:

Hey @eriktrautman https://github.com/eriktrautman, is this bounty completed? If so, who needs to be paid?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/near/bounties/issues/41#issuecomment-812612573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWW5HXVOIOQLG5FUL4QZHDTGXYW7ANCNFSM4XMVDLMA .

cameron-NEAR commented 3 years ago

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!

DenysOf commented 3 years ago

@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.

cameron-NEAR commented 3 years ago

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!

DenysOf commented 3 years ago

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 commented 3 years ago

Amazing! Thanks for the update. I'm looking forward to using it!

On Wed, May 12, 2021 at 4:44 PM Denys @.***> wrote:

Hey @cameron-NEAR https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/near/bounties/issues/41#issuecomment-840084392, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATLPOPHBIRZ2LE5S5HZ533LTNLSC7ANCNFSM4XMVDLMA .

DenysOf commented 3 years ago

@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.

cameron-NEAR commented 3 years ago

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

rencryptofish commented 3 years ago

did this ever get resolved?

cameron-NEAR commented 3 years ago

@rencryptofish - it is being worked on by @DenysOf

rencryptofish commented 3 years ago

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

DenysOf commented 3 years ago

@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/.near

DenysOf commented 3 years ago

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.

cameron-NEAR commented 3 years ago

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

DenysOf commented 3 years ago

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.

ilblackdragon commented 2 years ago

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