> For the complete documentation index, see [llms.txt](https://docs.eywa.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eywa.fi/developer-documentation/guide-for-developers/technical-documentation-for-eywa-dao-smart-contracts/delegationconditionvalidatorv1.md).

# DelegationConditionValidatorV1

### Overview <a href="#overview" id="overview"></a>

**DelegationConditionValidatorV1** This is an upgradeable contract that allows you to set additional conditions for delegating locks. It is integrated with **EscrowManager**, which allows you to know the current status of the lock when delegating it.

**Key Roles and Features:**

1. **Access Control:** Restricts **setAssuranceLockParameters** and **setMinLockVeEywa** calls to the **owner** of contract(`owner()`).
2. **Upgradeable via UUPS:** Uses **UUPSUpgradeable** and **OwnableUpgradeable** patterns, restricting contract upgrades to the owner.

***

### Inherited Contracts and Interfaces <a href="#inherited-contracts-and-interfaces" id="inherited-contracts-and-interfaces"></a>

* **UUPSUpgradeable (OpenZeppelin):**\
  Provides upgrade functionality under the UUPS proxy pattern, restricted to the contract owner.
* **OwnableUpgradeable (OpenZeppelin):**\
  Manages ownership, allowing only the owner to modify critical parameters and authorize upgrades.
* **IDelegationConditionValidatorV1:**\
  Defines core methods (e.g., `validateDelegations`) and events for this contract.

**Additional External References:**

* **IDelegationManagerV1:** Management of delegated locks
* **IEscrowManagerExtended:** Holds locked token data and checks voting power and freeze logic.

***

### State Variables <a href="#state-variables" id="state-variables"></a>

* **`s_escrowManager (IEscrowManagerExtended)`**\
  IEscrowManager interface for the EscrowManager contract.
* **`s_delegationManager (IDelegationManagerV1)`**\
  IDelegationManagerV1 for the DelegationManager contract.

***

### Constructor <a href="#constructor" id="constructor"></a>

```solidity
constructor() {
    _disableInitializers();
}
```

* **Description:**\
  Disables contract initializers to prevent re-initialization in a UUPS proxy context.

***

### External Functions (Defined by IDelegationConditionValidatorV1) <a href="#external-functions-defined-by-idelegationconditionvalidatorv1" id="external-functions-defined-by-idelegationconditionvalidatorv1"></a>

#### `initialize(...)` <a href="#initialize" id="initialize"></a>

```solidity
function initialize(
    address owner_,
    IEscrowManagerExtended escrowManager_,
    IDelegationManagerV1 delegationManager_
) external initializer;
```

**Description:**\
Configures ownership, references, and initial state:

* References the escrow manager and delegation manager.

**Parameters:**

* `owner_`: The address of the contract owner.
* `escrowManager_`: The IEscrowManager interface for the EscrowManager contract.
* `delegationManager_`: The IDelegationManagerV1 for the DelegationManager contract.

***

#### `validateDelegations(address delegator_, address delegatee_, uint256[] calldata tokenIds_)` <a href="#validatedelegations-address-delegator_-address-delegatee_-uint256-calldata-tokenids" id="validatedelegations-address-delegator_-address-delegatee_-uint256-calldata-tokenids"></a>

```solidity
function validateDelegations(
    address delegator_,
    address delegatee_,
    uint256[] calldata tokenIds_
) external view returns(bool);
```

**Description:**\
The function performs checks and determines whether delegation of `tokenIds_` from `delegator_` to `delegatee_` is possible.

**Parameters:**

* `delegator_`: The address of the contract owner.
* `delegatee_`: The IEscrowManager interface for the EscrowManager contract.
* `tokenIds_`: The IDelegationManagerV1 for the DelegationManager contract.

**Checks:**

* sender must be a **DelegationManager** contract. Otherwise, `UnauthorizedCaller()` is thrown

***

### Errors <a href="#errors" id="errors"></a>

* **`UnauthorizedCaller()`**\
  Thrown when the caller is not authorized to perform the action.

***

### Summary <a href="#summary" id="summary"></a>

**DelegationConditionValidatorV1** Being updatable in the long run can provide the opportunity for varied and flexible customization for delegated locks.
