EIPs Explained

ERC-5252 · Stagnant · ERC · 2022-06-29

ERC-5252: Account-bound Finance

Proposed a design pattern where each investor gets their own cloned finance contract, controlled only by whoever holds a matching account-bound NFT, so a protocol's operators cannot move user funds.

What problem does it solve?

Many DeFi protocols pool every user's funds in a handful of contracts, often behind upgradeable proxies and multisigs with broad powers. Users effectively trust the operators not to misuse those keys. The authors point to high-profile collapses as examples of what that trust can cost.

EIP-5252 proposes isolating funds per person instead: every investor gets a personal Finance contract, and only the holder of a credential token for that contract can move the money. Operator fees are separated out at deposit time, so the operators never hold the principal.

How it works

Interaction pattern (the core of the proposal):

  • Manager: entry point for investors; stores the financial parameters; the only contract allowed to ask the factory for new instances.
  • Factory: clones a uniform Finance implementation per user and is the only minter of the account-bound token.
  • Finance: holds one investor's funds. Every state-changing function requires the caller to own the matching token, except clearly marked /* global */ functions such as liquidation. Funds cannot leave without the token holder's signature.
  • Account-bound token: an ERC-721 credential (extending ERC-5114) whose metadata can show the position, for example as SVG. If transferable it is "account-bound" (lets you move a position between your wallets); if not, "soul-bound".
  • Extension / Metadata: optional contracts that can use locked funds with operator approval, or store credential data.

Governance pattern (secondary): voting power is staked tokens weighted by an "influence" multiplier derived from contributions recorded in these tokens (for example deposit size and holding time), and tokens are locked while a vote is open to prevent double voting.

The authors argue one-contract-per-user also saves gas over time, since users stop paying for storage shared with everyone else.

Sample code

A minimal Finance contract gated by ownership of its credential NFT:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IERC721 { function ownerOf(uint256 id) external view returns (address); }

contract Finance {
    IERC721 public abt;
    uint256 public abtId;
    bool private initialized;

    function initialize(IERC721 _abt, uint256 _abtId) external {
        require(!initialized, "init once");          // called once by the factory
        initialized = true;
        (abt, abtId) = (_abt, _abtId);
    }

    modifier onlyHolder() {
        require(abt.ownerOf(abtId) == msg.sender, "not credential holder");
        _;
    }

    receive() external payable {}

    function withdraw(address payable to, uint256 amount) external onlyHolder {
        (bool ok, ) = to.call{value: amount}("");
        require(ok, "send failed");
    }
}

A factory would deploy these as minimal-proxy clones (EIP-1167) and mint the credential to the investor.

Things to know

  • Status: Stagnant.
  • It is a design pattern rather than a fixed ABI: the spec lists roles and requirements but no function signatures for the interaction contracts.
  • The governance formulas are loosely specified (the worked example uses a "base factor" that the influence equation does not include), so treat that part as illustrative.
  • Whoever holds a transferable account-bound token controls the funds, so losing or selling the token is equivalent to losing the position.
  • Factories must register every clone and guard against reentrancy, or duplicate Finance contracts could corrupt accounting.

#defi #account-bound #design-pattern #governance #custody

Details

Authors
Hyungsuk Kang (@hskang9), Viktor Pernjek (@smuxx)
Status
Stagnant
Type
Standards Track / ERC
Created
2022-06-29
Requires

Machine-readable: Markdown · JSON