RealToken-Community / dashboard-v2

https://dashboard.realt.community/
5 stars 4 forks source link

More efficient rent calculation #25

Closed JSmithOner closed 9 months ago

JSmithOner commented 10 months ago

I was looking at the rent calculation and figured it would be nice to process it taking in account the rent start date. so for example in pseudo code

if ( token.rentStarDate.date <= Date.now() ) {
  ...
  weeklyRent += ( token.weeklyRentPerToken * quantity )
  ...
}

another example to better describe my idea would be to calculate the monthly and yearly rent amount by substracting the rent amount based on time of the tokens which did not started their rent yet.

I can work on this and make a pull request after but I would need additionnal guidelines concerning, first if the idea is approved then the code format, where I could put this infos...

One other great thing would be to grey out the rent amount in the property card where the token has not yet started its rent.

Best

NandyBa commented 10 months ago

Hi @JSmithOner, this feature can be a very nice one

NandyBa commented 10 months ago

Lines who need modifications to do so: https://github.com/RealT-Community/dashboard-v2/blob/3c040a33152ebae1a299ba1619e327cddf4a485b/src/store/features/wallets/walletsSelector.ts#L85-L97

Note: A modification of the property cards can also be done to indicate that the rent is not sarted yet

JSmithOner commented 10 months ago

@NandyBa Ok no additional guidelines ? I will start working on this...

jycssu-com commented 10 months ago

It would also be good to be able to activate/deactivate this mechanism because both options are interesting. This option could be added in the settings, where the user language and currency configuration is located

JSmithOner commented 10 months ago

@jycssu-com Ok I'm going to try doing that

NandyBa commented 10 months ago

@NandyBa Ok no additional guidelines ? I will start working on this...

Not, I have no other guidelines now.

JSmithOner commented 10 months ago

@NandyBa I've done the pull request what would be nice would be to gray out the cards now based on RentCalculation enum. There's a selector for that.I don't know how to do that so if you like my change and have time...Best

NandyBa commented 10 months ago

@JSmithOner I detected some ambiguity on your code refed in this comment (https://github.com/RealT-Community/dashboard-v2/commit/efb99cad62f5883b58c8765b8f85089a1613547d#r134163494) please consider it

JSmithOner commented 10 months ago

I've added another commit that takes in account the average token amount. Seems much more realtime now. yield is more fluctuant depending on whether you connect on a date where month has 0,..., 5 rent Day same for year calculation. I've tried it with my current rent of today and looks like everything is running fine. commit

jycssu-com commented 9 months ago

Merged to develop in #27