Below is a revised version of the Franchiser design document, featuring the addition of permissionless recall of funds after a specified expiration time.
This document describes a smart contract design which allows holders of COMP-style voting tokens to selectively delegate portions of their voting power to third parties for a specified duration, while retaining full custody over the underlying tokens.
Familiarity with the design and functionality of checkpoint voting tokens is assumed, for background information refer to the following reference material from e.g. Compound or OpenZeppelin.
Often, holders of voting tokens want to delegate their voting power, but not all to the same party or for an indefinite period! Because of how these tokens are designed, it's impossible to do so without splitting balances across multiple addresses. While this constraint is somewhat frustrating, it opens up an interesting design space.
Imagine a FranchiserFactory
contract designed to allocate voting tokens, with the following properties:
-
At any time, any voting token holder may specify some
amount
of voting power to give to adelegatee
for a specifiedexpiration
timestamp. This creates and funds aFranchiser
smart contract designed specifically for the holder, who becomes theowner
of the contract, and thedelegatee
.- The
Franchiser
contract allows theowner
to recall the delegated tokens on demand. - The
Franchiser
automatically delegates voting power to thedelegatee
with no further interaction required. - Anyone can call
recallExpired
to return the delegated tokens back to theowner
once theexpiration
timestamp is reached. - Anyone can call
recallManyExpired
to recall multiple expired instances ofFranchiser
in a single transaction. However, the operation will revert if any instance ofFranchiser
has not yet expired. This ensures atomic execution and prevents partial recalls. - The
owner
can update a delegatee'sFranchiser
expiration by callingfund
on it again. A zero value can be used, or an additional amount could be funded.
- The
-
Franchiser
contracts allowdelegatees
to further sub-divide their tokens amongst severalsubDelegatees
.- At any point before expiration, the
delegatee
of aFranchiser
may specify anamount
of voting power to give to asubDelegatee
, which creates and funds a nestedFranchiser
owned by thedelegatee
. - The
delegatee
may recall any delegated tokens on demand. - The maximum allowable number of
subDelegatees
varies. Thedelegatee
who was granted voting power by anowner
may designate up to 8subDelegatees
. Each of those may then specify 4subDelegatees
in turn, then 2, then 1, then 0. - While nested
Franchiser
contracts do not have explicitexpiration
timestamps, they are implicitly bound by their parent'sexpiration
. When a parentFranchiser
expires or is recalled, all tokens in its subdelegation tree are automatically recalled recursively.
- At any point before expiration, the
Note that at any level of nesting, a delegatee
(or owner
) always has the ability to recall any and all tokens they or any subsidiaries have delegated. The maximum number of nested delegatees
/subDelegatees
that any one owner
could be associated with is 16 (8 + 8*4 + 8*4*2 + 8*4*2), which costs about ~5m gas to fully unwind.