Moonwell is an open and decentralized lending and borrowing protocol built on Base, Optimism, Moonbeam, and Moonriver. We utilized eRPC to reduce RPC requests by two‑thirds, thereby enhancing operational efficiency and significantly lowering costs.
Moonwell relies heavily on real‑time data to provide users with accurate information about their assets and the broader market. Our application performs numerous multicalls and background polling every few seconds to update data across dozens of smart contracts and user wallets. This involves fetching the balanceOf
all collateral and underlying tokens for various markets, resulting in a staggering number of RPC requests. The high volume of these requests not only posed technical challenges but also led to significant RPC costs, impacting our operational efficiency.
Beyond the raw call volume, we saw frequent duplication of identical reads during bursts of user activity and re-renders. Having multiple regions amplified that duplication whenever front‑ends routed across POPs. The lack of an opinionated cache in front of our providers meant we were paying repeatedly for the same payloads and hitting provider‑specific rate limits faster than necessary.
To address these challenges, we adopted eRPC with the following infrastructure setup:
We utilized eRPC in‑memory cache, setting a maximum of 10 million items. This shift significantly improved data retrieval speeds and eliminated most duplicate upstream reads. For hot keys like eth_chainId
and chain metadata calls, hit rates were effectively instant.
Our deployment strategy ensured low‑latency access globally. We utilized Railway to deploy eRPC instances across four strategic regions:
Each region hosts a single eRPC instance, ensuring users are served from the nearest geographical location. A Cloudflare load balancer with dynamic traffic steering routes users to the closest eRPC instance based on real‑time latency measured from health checks, ensuring optimal performance.
Implementing eRPC has yielded impressive results for Moonwell. Below are the headline outcomes and a snapshot of the reduction in RPC activity after rollout.