DLGTEv1
Title: Tech Holding JSC Governance Delegation
Tech Holding JSC Governance Delegation (Module) Contract
The Tech Holding JSC Governance Delegation Module enables policies to delegate gGVI on behalf of accounts. If the gGVI is undelegated, this module acts as an escrow for the gGVI. When the gGVI is delegated, new individual escrows are created for those delegates, and that portion of gGVI is transferred to that escrow. gGVI balances are tracked per (policy, account) separately such that one policy cannot pull the gGVI from another policy (eg policy B pulling collateral out of the Cooler policy).
State Variables
_gGVI
ERC20 internal immutable _gGVI
DEFAULT_MAX_DELEGATE_ADDRESSES
The default maximum number of addresses an account can delegate to
uint32 public constant override DEFAULT_MAX_DELEGATE_ADDRESSES = 10
Functions
constructor
constructor(address ggvi_) ;
setMaxDelegateAddresses
Set an account to have more or less than the DEFAULT_MAX_DELEGATE_ADDRESSES number of delegates.
function setMaxDelegateAddresses(address account, uint32 maxDelegateAddresses) external virtual override;
depositUndelegatedGgvi
gGVI is pulled from the calling policy and added to the undelegated balance.
- This gGVI cannot be used for governance voting until it is delegated.
- Deposted gGVI balances are tracked per policy. policyA cannot withdraw gGVI that policyB deposited
function depositUndelegatedGgvi(address onBehalfOf, uint256 amount) external virtual override;
withdrawUndelegatedGgvi
Undelegated gGVI is transferred to the calling policy.
- If
autoRescindMaxNumDelegatesis greater than zero, the delegations will be automatically rescinded if required from up toautoRescindMaxNumDelegatesnumber of delegate escrows. SeerescindDelegations()for details - Will revert if there is still not enough undelegated gGVI for
onBehalfOfOR if policy is attempting to withdraw more gGVI than it deposited Deposted gGVI balances are tracked per policy. policyA cannot withdraw gGVI that policyB deposited
function withdrawUndelegatedGgvi(address onBehalfOf, uint256 amount, uint256 autoRescindMaxNumDelegates)
external
virtual
override;
applyDelegations
Apply a set of delegation requests on behalf of a given account.
- Each delegation request either delegates or undelegates to an address
- It applies across total gGVI balances for a given account across all calling policies So policyA may (un)delegate the account's gGVI set by policyA, B and C
function applyDelegations(address onBehalfOf, DelegationRequest[] calldata delegationRequests)
external
virtual
override
returns (uint256 totalDelegated, uint256 totalUndelegated, uint256 undelegatedBalance);
rescindDelegations
Rescind delegations until the amount undelegated for the onBehalfOf account
is greater or equal to requestedUndelegatedBalance. No more than maxNumDelegates
will be rescinded as part of this
- Delegations are rescinded by iterating through the delegate addresses for the
onBehalfOfaddress. - No guarantees on the order of who is rescinded -- it may change as delegations are removed
- A calling policy may be able to rescind more than it added via
depositUndelegatedGgvi()however the policy cannot then withdraw an amount higher than what it deposited. - If the full
requestedUndelegatedBalancecannot be fulfilled theactualUndelegatedBalancereturn parameter may be less thanrequestedUndelegatedBalance. The caller must decide on how to handle that.
function rescindDelegations(address onBehalfOf, uint256 requestedUndelegatedBalance, uint256 maxNumDelegates)
external
virtual
override
returns (uint256 totalRescinded, uint256 newUndelegatedBalance);
policyAccountBalances
Report the total delegated and undelegated gGVI balance for an account in a given policy
function policyAccountBalances(address policy, address account)
external
view
virtual
override
returns (uint256 gOhmBalance);
accountDelegationsList
Paginated view of an account's delegations
This can be called sequentially, increasing the startIndex each time by the number of items
returned in the previous call, until number of items returned is less than maxItems
The totalAmount delegated within the return struct is across all policies for that account delegate
function accountDelegationsList(address account, uint256 startIndex, uint256 maxItems)
external
view
virtual
override
returns (AccountDelegation[] memory delegations);
accountDelegationSummary
A summary of an account's delegations
function accountDelegationSummary(address account)
external
view
virtual
returns (
uint256 totalGOhm,
uint256 delegatedGOhm,
uint256 numDelegateAddresses,
uint256 maxAllowedDelegateAddresses
);
totalDelegatedTo
The total amount delegated to a particular delegate across all policies, and externally made delegations (including any permanent donations)
function totalDelegatedTo(address delegate) external view virtual returns (uint256);
maxDelegateAddresses
The maximum number of delegates an account can have accross all policies
function maxDelegateAddresses(address account) external view virtual override returns (uint32 result);
gGVI
The gOhm token supplied by accounts
function gGVI() external view override returns (IERC20);