Skip to main content

DelegateEscrow

Git Source

Inherits: Clone

Title: Delegate Escrow Account

An escrow to hold gOHM 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 gOHM back. This contract uses Clones (https://github.com/wighawag/clones-with-immutable-args) to save gas on deployment. Note: Any donated gOHM (transferred directly rather than using delegate()) cannot be recovered.

State Variables​

gohm​

OHM governance token

ERC20 public immutable gohm

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 gohm_) ;

initialize​

function initialize() external onlyFactory;

delegateAccount​

The delegate address of the gOHM 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 gOHM to the predefined delegateAccount

gOHM is pulled from the caller (which must provide allowance), and only that same caller may rescind the delegation to recall the gOHM at a future date.

function delegate(address onBehalfOf, uint256 gohmAmount) external returns (uint256 delegatedAmount);

rescindDelegation​

Rescind a delegation of gOHM and send back to the caller.

function rescindDelegation(address onBehalfOf, uint256 gohmAmount) 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 gOHM which was delegated.

error ExceededDelegationBalance();

NotFactory​

Can only be called from the factory which created this contract

error NotFactory();