> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mystockline.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Timelock

> Timelock is the owner of RiskRegistry, FeeCollector, and other governed contracts.

Timelock is the owner of RiskRegistry, FeeCollector, and other governed contracts. A single proposer schedules calls, and anyone can execute them after `minDelay`. It holds no ETH, cannot change its delay, and does not delegatecall. Launch delay is 48 hours.

`Timelock` lets you:

* Let the proposer schedule a call to a target
* Let anyone execute a scheduled call after the delay
* Let the proposer cancel a pending call
* Compute operation ids and read their ready times

Addresses per network. Every address is also on [Addresses](/resources/addresses).

| Network                 | Address                                                                                                                                       |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Robinhood Chain testnet | [0xbcfe5fA131F5f6813116cD661c77A37C4c2a465e](https://explorer.testnet.chain.robinhood.com/address/0xbcfe5fA131F5f6813116cD661c77A37C4c2a465e) |

The source code is [`src/governance/Timelock.sol`](https://github.com/stockline-xyz/contracts/blob/main/src/governance/Timelock.sol) on GitHub. The ABI is [`/abis/Timelock.json`](/abis/Timelock.json).

## Write methods

### schedule

```solidity theme={"system"}
function schedule(
    address target,
    bytes calldata data,
    bytes32 salt
) external returns (bytes32 id)
```

Queues a call for execution at `block.timestamp + minDelay`. Proposer only. Reverts with ZeroAddress for a zero target and AlreadyScheduled if the same (target, data, salt) is already pending.

<Warning>
  Proposer only. Reverts with NotProposer otherwise.
</Warning>

**Input parameters**

| Name   | Type      | Description                                                  |
| ------ | --------- | ------------------------------------------------------------ |
| target | `address` | The contract to call.                                        |
| data   | `bytes`   | ABI-encoded calldata.                                        |
| salt   | `bytes32` | Arbitrary value so identical calls can be queued separately. |

**Return values**

| Type      | Description                                                  |
| --------- | ------------------------------------------------------------ |
| `bytes32` | id: The operation id, equal to `hashOp(target, data, salt)`. |

### execute

```solidity theme={"system"}
function execute(
    address target,
    bytes calldata data,
    bytes32 salt
) external
```

Runs a scheduled call once its ready time has passed. Anyone can call it. Reverts with UnknownOp if not scheduled, NotReady before the ready time, and ExecuteFailed if the target call reverts. The operation is cleared before the call.

<Note>
  Permissionless execution means a scheduled change will land as soon as anyone submits it after the delay.
</Note>

**Input parameters**

| Name   | Type      | Description             |
| ------ | --------- | ----------------------- |
| target | `address` | The scheduled target.   |
| data   | `bytes`   | The scheduled calldata. |
| salt   | `bytes32` | The scheduled salt.     |

### cancel

```solidity theme={"system"}
function cancel(bytes32 id) external
```

Removes a pending operation. Proposer only. Reverts with UnknownOp if nothing is scheduled under `id`.

<Warning>
  Proposer only.
</Warning>

**Input parameters**

| Name | Type      | Description                                   |
| ---- | --------- | --------------------------------------------- |
| id   | `bytes32` | The operation id from `schedule` or `hashOp`. |

## Read methods

### hashOp

```solidity theme={"system"}
function hashOp(
    address target,
    bytes calldata data,
    bytes32 salt
) public pure returns (bytes32)
```

Computes the operation id as `keccak256(abi.encode(target, data, salt))`.

**Input parameters**

| Name   | Type      | Description      |
| ------ | --------- | ---------------- |
| target | `address` | Target contract. |
| data   | `bytes`   | Calldata.        |
| salt   | `bytes32` | Salt.            |

**Return values**

| Type      | Description   |
| --------- | ------------- |
| `bytes32` | Operation id. |

## Events

### Scheduled

```solidity theme={"system"}
event Scheduled(
    bytes32 indexed id,
    address indexed target,
    bytes data,
    bytes32 salt,
    uint256 readyAt
)
```

Fires when an operation is queued, with its target, calldata, salt, and ready time.

### Executed

```solidity theme={"system"}
event Executed(bytes32 indexed id, address indexed target)
```

Fires after an operation runs successfully.

### Cancelled

```solidity theme={"system"}
event Cancelled(bytes32 indexed id)
```

Fires when the proposer removes a pending operation.

## Errors

### ZeroAddress

```solidity theme={"system"}
error ZeroAddress()
```

The proposer or target was the zero address.

### InvalidDelay

```solidity theme={"system"}
error InvalidDelay()
```

The constructor delay was below 10 seconds or above 30 days.

### NotProposer

```solidity theme={"system"}
error NotProposer()
```

Only the proposer can schedule or cancel.

### AlreadyScheduled

```solidity theme={"system"}
error AlreadyScheduled()
```

An identical operation is already pending.

### UnknownOp

```solidity theme={"system"}
error UnknownOp()
```

No operation is scheduled under this id.

### NotReady

```solidity theme={"system"}
error NotReady()
```

The delay has not passed yet.

### ExecuteFailed

```solidity theme={"system"}
error ExecuteFailed()
```

The target call reverted.
