ERC-5252 Account-bound finance (personal vault) (Account-bound Finance)

Stagnant · Vaults & DeFi · created 2022-06-29

A design pattern that creates a separate personal finance contract for each investor, separating operator funds from investor funds, and granting access to that contract only through an account-bound token (ABT).

Why it is needed

In current DeFi contracts, logic is often hidden behind a separate proxy, and the funds of all investors are commonly pooled together in a single operating contract. On top of this, an overly privileged multisig wallet often controls the funds. Investors have to trust this small number of contracts and the operator's keys as-is, and in practice there have been cases of major losses, such as the Celsius bankruptcy, the UST depegging, and the Anchor protocol failure, where investors could not independently verify whether assets were adequately collateralized. In other words, this is a structure where users do not actually own their own funds and the risk of loss is left to the operator's discretion.

In depth

Contract composition of the interaction pattern

This pattern consists of six contracts: Manager, Factory, Finance, account-bound token (ABT), Extension, and Metadata. Manager is the first point of contact with investors and stores Finance's financial parameters. Factory is the sole entity that clones Finance contracts from a uniform implementation, the sole contract that mints ABTs, and manages the most recently issued token id. Finance defines all the rules governing investor funds and can only be accessed by an account holding the ABT. ABT can pull data from Finance and append metadata for display, and Extension is a separate contract (e.g. membership) that, with the Manager's approval, makes use of funds locked in Finance. Metadata stores credential-related data by key, with images typically represented as SVG and optionally off-chain as well.

Conditions for account-bound/soulbound tokens

This token must be a non-fungible token conforming to ERC-721. It is recommended that the credential be represented via the metadata returned by the tokenURI() function. The token must verify whether it has been minted by referencing only the Factory. If transferable, it is classified as account-bound; if non-transferable, it is classified as soul-bound.

Access restriction rules for the Finance contract

The Finance contract must be initialized exactly once, in the Factory's constructor. Funds within the contract cannot be transferred to another contract or account unless signed by the ABT holder. Except for global functions such as liquidation, all state-changing functions must be callable only by the ABT holder, and any globally accessible function must be explicitly marked with a /* global */ comment. Each Finance contract must be able to represent transactions only with the ABT holder, or, in the soul-bound token scheme, only transactions between the private key holder and Finance.

Governance: Influencer and Governor

The Influencer contract must manage the voting multiplier, set the decimal precision for computing normalized scores, and provide a function through which governance can determine the factor parameter. The Governor contract must conform to the OpenZeppelin Governor specification, must reference the Influencer to obtain the multiplier, and an ABT that has already been used to vote must have its transfer restricted to prevent double voting.

Calculating and normalizing contribution scores

The score per ABT is calculated as alpha*(contribution per Finance contract as of the current proposal) + beta*(duration held up to the current point in time). The normalized score is each term divided by the total sum of contributions and the time elapsed from genesis to the proposal, respectively; since alpha+beta=1, the value falls between 0 and 1. Influence is defined as a linear multiplier m*(sum of normalized scores); for example, with three ABTs having normalized scores of 1.0, 0.5, and 0.3, a base factor of 1.5, a multiplier of 0.5, and 100 locked tokens, the influence is 1.8, and the voting power is 1.8*sqrt(100)=18.

Distinction between Stakers and Enforcers roles

Stakers are the majority group that stakes governance tokens, votes on Enforcer proposals, and receives dividends, with voting power calculated as sqrt(locked tokens). Enforcers are a minority who bear protocol operating risk and propose rule changes, with voting power calculated as influence*sqrt(locked tokens), giving them greater influence.

Rationale for gas savings from per-user contract separation

If the entire state of all users is stored in a single contract, each subsequent user who interacts with it also ends up sharing the storage costs of all other users. The original text cites the example of MakerDAO contracts, where operating costs sometimes exceeded 0.1 ETH, leading to a minimum CDP deposit being capped to save gas, and explains that to avoid this inefficiency, using one contract per user via the clone factory pattern saves gas in the long run.

Still a stalled proposal

This ERC is currently in Stagnant status, a proposal that is no longer being actively discussed or finalized and remains stalled. Its content may change or it may never be adopted.

Things to watch out for

Original ERC · ← ERCs