RigoBlock / webapp

RigoBlock webapp v1
0 stars 3 forks source link

Improve data fetching #156

Open wnz99 opened 5 years ago

wnz99 commented 5 years ago

Mainnet is generally slow, therefore we need to find ways to improve the dapp responsiveness.

One part of the job is to optimize the number of calls to the back-end node (currently Infura).

At the moment the dapp gathers info by doing various calls to various methods. For example:

  let dragoData = poolApi.contract.drago.getData()
  let dragoTotalSupply = poolApi.contract.drago.totalSupply()
  let dragoETH = poolApi.contract.drago.getBalance()
  let dragoWETH = poolApi.contract.drago.getBalanceWETH()

It would be very helpful if that could be accomplished with a single call. The above is just an example, therefore we should review the protocol contracts to see what information can be centralized in a single proxy contract. The most, the better.

A further step could be to have the proxy to return an array of funds, so for example we could call the proxy and pass an array of pools' addresses, and the fund would return ad array of information (those previously suggested).

This would help a lot when we need to show information for many funds, for example in the home page:

image

In the above screen I would like to show the fund's prices, supply and so on. This means that dapp needs to make calls for each funds. A good solution would be to call the proxy funds with batches of 5 funds each time (or more if feasible), so that the dapp would only make 1 single call for each page.

gabririgo commented 5 years ago

this one addresses the first 3 at once https://github.com/RigoBlock/rigoblock-monorepo/blob/feature/drago-data-helper/packages/contracts/src/examples/helpers/HGetDragoData.sol cannot return more data for stack too deep

multiple token balances for a drago can be queried at once by calling this: https://github.com/RigoBlock/rigoblock-monorepo/blob/ce3fc181c154c2bd8c0a7a6ddfe3b6b94b10e162/packages/contracts/src/examples/helpers/HGetMultipleBalances.sol#L58

by combining the two, you could potentially reduce down to 2 what is now done in 3 + x token pairs calls.

If works in principle, can work more on it, test and deploy.