SKIP TO CONTENT
Security

Proxy Pattern

A smart contract architecture enabling upgrades by separating storage from logic through delegatecall.

What is Proxy Pattern?

The proxy pattern is a smart contract architecture that separates a contract's storage from its logic, enabling the logic to be upgraded while preserving the stored data and contract address. This is achieved through the delegatecall opcode, which executes another contract's code in the context of the calling contract's storage.

How it Works

In the proxy pattern, users interact with a proxy contract that holds all state and funds. When a function is called, the proxy forwards the call to an implementation contract using delegatecall. The implementation's code executes but reads and writes to the proxy's storage. Upgrading the protocol simply involves pointing the proxy to a new implementation contract.

The key components include:

  1. Proxy Contract: Holds storage, funds, and the address of the current implementation
  2. Implementation Contract: Contains the business logic
  3. Admin/Upgrade Mechanism: Controls which implementation the proxy uses
  4. Storage Layout: Must remain consistent across upgrades

Practical Example

Compound Finance uses the proxy pattern to upgrade its lending protocol without requiring users to migrate funds to new contracts. When a bug was discovered in their governance system, they deployed a fixed implementation and updated the proxy to point to it. Users continued interacting with the same addresses while benefiting from the patched code. Most major DeFi protocols including Aave, Uniswap governance, and OpenSea use some form of proxy pattern.

Why it Matters

While the proxy pattern enables crucial bug fixes and feature upgrades, it also introduces significant trust requirements and potential vulnerabilities. Users must trust that upgrade administrators will not deploy malicious implementations. Storage collisions, initialization bugs, and selector clashes have all caused significant losses. Understanding proxy patterns helps users evaluate the trade-offs between upgradeability and immutability in DeFi protocols.

Fensory analyzes protocol architectures including proxy implementations, helping users understand the upgradeability and associated trust requirements of their DeFi positions.

Examples

  • Compound Finance uses proxies to upgrade lending contracts without fund migration
  • OpenSea used a proxy upgrade to fix a critical vulnerability in 2022

Theory meets practice. See current rates across DeFi.

Track live yields, compare protocols, and build your DeFi portfolio with Fensory.

GET EARLY ACCESSArrow right