delvtech / hyperdrive-frontend

A monorepo of apps and packages for the Hyperdrive AMM.
https://hyperdrive.box
Apache License 2.0
10 stars 1 forks source link

Add multicall support to ReadContract #1559

Open DannyDelott opened 1 month ago

DannyDelott commented 1 month ago

The Compute Unit cost of using eth_getLogs is almost 3x higher than a standard eth_call, eg: calling balanceOf. Currently, we make two eth_getLogs calls to track a user’s open positions—one to get all events where they received tokens, and another for when they sent tokens. By using multicall via Drift, we can optimize this by making just one eth_getLogs request for receiving tokens, and then a single multicall3 eth_call to batch request balanceOf and check if they still hold a balance. This should also make the portfolio load faster, and our sdk logic quite a bit simpler (no need to reduce over two event arrays)

Image

DannyDelott commented 2 weeks ago

We should wait to do this until we rewrite the SDK using Drift