RealToken-Community / dashboard-v2

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

added rent page #31

Open JSmithOner opened 11 months ago

JSmithOner commented 11 months ago

@jycssu-com I cannot see the Drawer, I've created the branch then executed git pull any ideas?

JSmithOner commented 11 months ago

@jycssu-com ok you meant the menu on the left, got it

JSmithOner commented 11 months ago

@jycssu-com Is it possible to retrieve the trnasactions in USDC ETH WXDAI ... to calculate the buying and seeling cost of a token. I've called the "rent page" "statistics" where we can find detailed statistics on profits.Thanks

NandyBa commented 11 months ago

@jycssu-com Is it possible to retrieve the trnasactions in USDC ETH WXDAI ... to calculate the buying and seeling cost of a token. I've called the "rent page" "statistics" where we can find detailed statistics on profits.Thanks

You want the current price (aka oracle current price) or explicitly need price on the past ?

JSmithOner commented 11 months ago

@NandyBa I would like the price bought on the YAM no need for RealT because it can be any wallet an prices are stable

jycssu-com commented 11 months ago

I had already started to imagine a solution to recover this information. In the graph on which we retrieve the transfers (TransferEvent), there is information on the transaction that triggered them (TransferEvent.transaction). We already recover certain data from it, in particular the id and the recipient (id, to)

This Transaction object has an input property, with data sent to the blockchain. In the case of a Yam/Swapcat transaction, they therefore make it possible to determine the purchase price since it is included in the call. It will be necessary to parse this data via the ABI of these contracts (close example in currencies.repository.ts).

The problem is that we cannot afford to retrieve the input property for all transactions. In the case of sending tokens by RealT (purchase or reinvestment), it contains all the data from their batch, which would cause us to reach too quickly the size limit of a query response from TheGraph (2MB), and they are not necessary for us.

The idea would therefore be to make a more complex query to the SubGraph. One to retrieve Yam-related transactions (and perhaps another for Swapcat), with the input property included, and a final one containing all other transactions, without the input property.

I don't know if you are comfortable with TheGraph/GraphQL and SmartContract, but if you want, I can help implement this logic fairly quickly

JSmithOner commented 11 months ago

@jycssu-com I'll make a deep dive into the code and get back to you soon, I'm not comfortable with GraphQl but I can learn also I executing multiple queries for 1 token at a time which could possibly avoid the 2Mb problem

jycssu-com commented 11 months ago

Ideally, the number of requests should still be limited (in the http sense). It should not be a problem to do everything in a single http request given that it is possible to make several GraphQL queries within the same http request. If this is not possible (because too heavy), above all, you should not make queries per property, but one for all transactions on the YAM (for all properties) and another for all other transactions (also for all properties).

And in all cases, it will probably be necessary to set up pagination in a second step (TheGraph limiting to 1000 objects per request), which means that we should never reach the limit of 2MB, as long as we do not fetch the input field of transactions made by RealT

When using TheGraph, you must keep in mind that you must limit the number of http requests as much as possible, because there is a chance that its use will eventually become payable, with billing per http call

JSmithOner commented 11 months ago

@jycssu-com Ok I've looked at a tutorial on ABI and understand a bit more now.

Did you know we can create an API out of Google Sheets also firebase would be a good option to store any data and updates made to the RealT properties with a free tier. There is also supabase which is in postgresql (only ideas but I know all the technologies mentionned).

Retrieving all transactions from RealT input seems unnecessary as an api call is already made to realT community API to get the tokens infos (for example price).

Please let me know what you think of my ideas and please tell me if you want me to work on something particular.

Also one last thing, I'm using GetRealTokenTransfers and this function doesn't allow me to see quickly which transfer is related to which token, wouldn't it ba a good idea to update this function and perhaps add the ABI thing in a lower level to retrieve all informations in a clean manner?Best.

JSmithOner commented 11 months ago

@jycssu-com I've made a quick api with a unique API key using firebase which enables yu to get updates are you interested?