fix(insights): use web3.js Connection instead of PythConnection #3158
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.

Upon investigation, it seems the
PythConnectionfrom@pythnetwork/clientis extremely inefficient for a few reasons:PythConnectionrequires loading all account info when creating the connection class, so that it can build a mapping from price account to program account. However IH never used this mapping in practice, so all of that was wasted work. This caused major issues for page load performance as loading all account info from pythnet was a ton of parsing which locked up the browser for multiple seconds.PythConnectiondid not expose a mechanism to remove unused subscriptionsIn doing this I also removed all the live prices contexts since none of that is needed any more, as well as the call to initialize prices with the last available price as that too looks unnecessary and redundant.
This change should drastically improve performance in IH, especially during page load.