# Validators Registry

The Validator Registry contract stores an approved validators whitelist.

The main query of the contract - [`GetValidatorsForDelegation` ](#getvalidatorsfordelegation)returns a list of approved validators sorted by total\_delegated amount.

The [Hub ](https://docs.kryptonite.finance/developer/staking/broken-reference)uses this query to equally distribute delegations between validators.

## Config

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Config {
    pub owner: CanonicalAddr,
    pub hub_contract: CanonicalAddr,
}
```

<table><thead><tr><th width="162">Key</th><th width="194">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>CanonicalAddr</td><td>Owner of the contract</td></tr><tr><td>hub_contract</td><td>CanonicalAddr</td><td>Contract address of <a href="broken-reference">Hub</a></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

## InitMsg

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub registry: Vec<Validator>,
    pub hub_contract: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Validator {
    pub address: String,
}

```

<table><thead><tr><th width="171">Key</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td>registry</td><td>Vec&#x3C;Validator></td><td>List of whitelisted validators</td></tr><tr><td>hub_contract</td><td>String</td><td>Contract address of <a href="broken-reference">Hub</a></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

<table><thead><tr><th width="171">Key</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td>Operator address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

## ExecuteMsg

### AddValidator

Adds a validator to the registry. Can only be executed by the owner.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    AddValidator { validator: Validator },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Validator {
    pub address: String,
}
```

<table><thead><tr><th width="169">Key</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td>validator</td><td>Validator</td><td>validator struct</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

<table><thead><tr><th width="171">Key</th><th width="189">Type</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td>Operator address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### RemoveValidator

Removes a validator from the registry. Can only be executed by the owner.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    RemoveValidator { address: String},
}
```

<table><thead><tr><th width="178">Key</th><th width="187">Type</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td>Operator address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### UpdateConfig

Updates a registry's configuration. Can only be issued by the owner.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    UpdateConfig {
        hub_contract: Option<String>,
    },
}
```

<table><thead><tr><th width="178">Key</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td>hub_contract*</td><td>String</td><td>New contract address of <a href="broken-reference">Hub</a></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

\* = optional

### Redelegations

Re-delegate the delegation from the validator which removed to other whitelisted validator nodes.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    Redelegations { address: String }, 
}
```

<table><thead><tr><th width="183">Key</th><th width="191">Type</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td>Operator address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### SetOwner

Transfer ownership permissions to a new owner address.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
 SetOwner {
        new_owner_addr: String,
    },
}
```

<table><thead><tr><th width="188">Key</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>new_owner_addr</td><td>String</td><td>The address of new owner</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### AcceptOwnership

The new owner accepts ownership permissions.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    AcceptOwnership {},
}
```

## QueryMsg

### GetValidatorsForDelegation

Returns validators sorted by total\_delegated amount.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    GetValidatorsForDelegation {},
}
```

### ValidatorResponse

returns list validatorResponse

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ValidatorResponse {
    #[serde(default)]
    pub total_delegated: Uint128,
    pub address: String,
}
```

<table><thead><tr><th width="183">Key</th><th width="178">Type</th><th>Description</th></tr></thead><tbody><tr><td>total_delegated</td><td>Uint128</td><td>total Sei delegated to validator</td></tr><tr><td>address</td><td>String</td><td>Operator address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### Config

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Config {},
}
```

Returns a [Config ](#config)struct.

### NewOwner

Query the address of the new owner.

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
  NewOwner {},
}
```

### NewOwnerResponse

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct NewOwnerResponse {
    pub new_owner: String,
}
```

<table><thead><tr><th width="186">Key</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td>new_owner</td><td>String</td><td>The address of new owner</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>
