DelegateEscrow
Inherits: Clone
Title: Delegate Escrow Account
An escrow to hold gGVI and delegate that amount to exactly one account.
Any caller (eg MonoCooler) can delegate on behalf of a delegator address, but only that same caller
can rescind the delegation to pull the gGVI back.
This contract uses Clones (https://github.com/wighawag/clones-with-immutable-args)
to save gas on deployment.
Note: Any donated gGVI (transferred directly rather than using delegate()) cannot be recovered.
State Variables
ggvi
GVI governance token
ERC20 public immutable ggvi
delegations
The mapping of delegation amounts.
Partitioned by the calling address, and also by the address on behalf it is delegating for.
mapping(address /* caller */ => mapping(address /* onBehalfOf */ => uint256 /* amount */)) public delegations
Functions
constructor
constructor(address ggvi_) ;
initialize
function initialize() external onlyFactory;
delegateAccount
The delegate address of the gGVI collateral in this escrow
function delegateAccount() public pure returns (address);
factory
The factory contract which created this escrow
function factory() public pure returns (DelegateEscrowFactory _factory);
delegate
Delegate an amount of gGVI to the predefined delegateAccount
gGVI is pulled from the caller (which must provide allowance), and only that same caller may rescind the delegation to recall the gGVI at a future date.
function delegate(address onBehalfOf, uint256 ggviAmount) external returns (uint256 delegatedAmount);
rescindDelegation
Rescind a delegation of gGVI and send back to the caller.
function rescindDelegation(address onBehalfOf, uint256 ggviAmount) external returns (uint256 delegatedAmount);
totalDelegated
The total amount delegated via this escrow across all callers, including donations.
function totalDelegated() external view returns (uint256);
onlyFactory
Ensure that the caller is the factory which created this contract only.
modifier onlyFactory() ;
Errors
ExceededDelegationBalance
A caller cannot rescind a delegation for more the gGVI which was delegated.
error ExceededDelegationBalance();
NotFactory
Can only be called from the factory which created this contract
error NotFactory();