# DLGTE.v1.sol (Delegation Module)

DLGTE manages governance power of gOHM while it's being used as collateral in Cooler. Each account's gOHM can be split between multiple delegates through individual escrow contracts, allowing governance participation even while the gOHM is locked.

The module tracks balances per policy (like MonoCooler) and per user, ensuring one policy can't withdraw gOHM deposited by another. Users can delegate to up to 10 addresses by default (governance can whitelist a contract for >10), with each delegate getting their own escrow contract.

### Functions by Category

#### Core Tracking Functions

`depositUndelegatedGohm(address onBehalfOf, uint256 amount)`

* Takes gOHM from a policy and tracks it for a user
* gOHM stays undelegated in the module until delegation requests

`withdrawUndelegatedGohm(address onBehalfOf, uint256 amount)`

* Returns undelegated gOHM to a policy
* Amount must be available (not currently delegated)
* Can only withdraw amount deposited by calling policy

#### Delegation Management

`applyDelegations(address onBehalfOf, DelegationRequest[] calldata delegationRequests)`

* Updates how a user's gOHM is delegated
* Can delegate or undelegate to multiple addresses
* Creates or retrieves escrow contracts as needed
* Returns amounts delegated/undelegated and current undelegated balance

`setMaxDelegateAddresses(address account, uint32 maxDelegateAddresses)`

* Changes maximum number of delegates for an account
* Default is 10 if not set

#### View Functions

`policyAccountBalances(address policy, address account)`

* Shows total gOHM balance a policy deposited for an account

`accountDelegationsList(address account, uint256 startIndex, uint256 maxItems)`

* Returns paginated list of account's delegations
* Each entry shows delegate address, escrow contract, and amount

`accountDelegationSummary(address account)`

* Shows total gOHM, amount delegated, delegate count and max allowed delegates

`maxDelegateAddresses(address account)`

* Returns maximum number of delegates allowed for account
