EIPs Explained

ERC-7246 · Review · ERC · 2023-06-27

ERC-7246: Encumber - Splitting Ownership & Guarantees

An ERC-20 extension that lets a holder lock part of their balance in favour of another account without transferring it, giving a stronger guarantee than an allowance while the owner keeps the tokens.

What problem does it solve?

Many protocols need to be sure that tokens will be there when they need them: collateral for a loan, a bond for a service, a stake behind a promise. An ERC-20 allowance is not enough, because the owner can still spend the tokens after approving. So today users usually transfer tokens into the protocol's contract.

That has costs. The owner loses visible ownership, airdrops and other perks of holding go to the contract instead, and a single contract holding everyone's tokens is a honeypot that can be drained in one transfer. ERC-7246 ("Encumber") lets the tokens stay in the owner's wallet while guaranteeing another account the exclusive right to take them.

How it works

An encumbrance is like an allowance that the owner cannot undercut:

  • encumber(taker, amount) reserves amount of the caller's balance for taker. It reverts if the caller does not have that much unencumbered balance.
  • encumberFrom(owner, taker, amount) does the same on behalf of an owner who has authorised the caller through some mechanism (the reference implementation reuses the ERC-20 allowance).
  • release(owner, amount) is called by the taker to give up some or all of its claim.
  • encumbrances(owner, taker) and encumberedBalanceOf(owner) expose the per-taker and total locked amounts; availableBalanceOf(owner) is balanceOf - encumberedBalanceOf.
  • Encumber and Release events let indexers track changes.

The one hard rule: any function that would push balanceOf(owner) below encumberedBalanceOf(owner) must revert. So transfer only spends the available portion, and the taker collects by calling the ordinary transferFrom, which consumes its encumbrance first.

Sample code

Using an encumberable token as loan collateral (sketch):

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

interface IERC7246 {
    event Encumber(address indexed owner, address indexed taker, uint amount);
    event Release(address indexed owner, address indexed taker, uint amount);
    function encumberedBalanceOf(address owner) external returns (uint);
    function encumbrances(address owner, address taker) external returns (uint);
    function encumber(address taker, uint amount) external;
    function encumberFrom(address owner, address taker, uint amount) external;
    function release(address owner, uint amount) external;
    function availableBalanceOf(address owner) external view returns (uint);
}

interface IERC20 {
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

contract SimpleLender {
    address public immutable token; // ERC-20 + ERC-7246

    constructor(address t) { token = t; }

    // Borrower first calls token.encumber(address(this), amount) themselves.
    function repaid(address borrower, uint amount) external /* onlyAuthorized */ {
        IERC7246(token).release(borrower, amount);          // unlock collateral
    }

    function liquidate(address borrower, uint amount) external /* onlyAuthorized */ {
        IERC20(token).transferFrom(borrower, address(this), amount); // seize it
    }
}

Things to know

  • Status: Review. The interface may still change before it is finalised.
  • Integrators that read balanceOf to decide what a user can spend should use availableBalanceOf (or balanceOf - encumberedBalanceOf) instead.
  • Rebasing tokens, admin burns or any other path that changes balances must add their own guards so balances never fall below the encumbered amount.
  • How encumberFrom is authorised is left to the implementer; the reference code reuses approve, but a separate approveEncumber is also allowed.
  • The authors note the same idea can be adapted to ERC-721 by treating amount as a tokenId, but the interface is written for ERC-20.

#token #erc20 #collateral #locking #extension

Details

Authors
Coburn Berry (@coburncoburn), Mykel Pereira (@mykelp), Scott Silver (@scott-silver)
Status
Review
Type
Standards Track / ERC
Created
2023-06-27
Requires

Machine-readable: Markdown · JSON