---
# System prepended metadata

title: Stream Agreement Transition Subsystem Math Spec
tags: [Spec-Agreements]

---

---
tags: Spec-Agreements
---

# Stream Agreement Transition Subsystem Math Spec

This math spec takes care of the transition phase between an agreement spinning up and being deployed.

## Global State

#### System State
| Symbol | Description | Domain |
| --------|------- | ----- |
| $\hat{\Gamma}$|  Set of Agreements Spinning Up| |
| $\Gamma$|  Set of Live Agreements| |

## Local State (Agent Level)

| Symbol | Description | Domain | Initial Value |
| --------|------- | ----- | ----- |
| $R_i$|  Unallocated Funds| $\mathbb{R}_+$| $R_{0}$|
| $\mathcal{B}_i$|  Set of all Committed Brokers | | $\emptyset$|

#### Stateful Metrics
These variables can all be computed from variables within either the local or global state.

| Symbol | Description | Domain | Initial Value |
| --------|------- | ----- | ----- |
|$n_i$ $(= \vert \mathcal{B_i}\vert)$|Number of Committed Brokers|$\mathbb{R}_+$, $[0, n_{\min,i})$|$0$|

#### Parameters

| Symbol | Description | Domain |
| --------|------- | ----- |
|  $s_{\min,i}$   | Minimum Stake     | $\mathbb{R}_{+}$ |
|  $\Delta t_{i}$   | Epoch Length     | $\mathbb{R}_{+}$ |
|  $\tau_{i}$  | Minimum Epochs     | $\mathbb{R}_{+}$ |
|  $\Delta A_{i}$  | Allocation Per Epoch     | $\mathbb{R}_{+}$ |
|  $H_{\min,i}$ | Minimum Horizon     | $\mathbb{R}_{+}$ |
|  $n_{\min,i}$ | Minimum Number of Brokers     | $\mathbb{R}_{+}$ |
|  $n_{\max,i}$ | Maximum Number of Brokers     | $\mathbb{R}_{+}$ |
|  $R_{0,i}$ | Initial Funding     | $\mathbb{R}_{+}$ |
|  $\Delta F_{i}$| Payer Payments per Epoch    | $\mathbb{R}_{+}$ |

## Mechanisms

### Owner Mechanisms

#### Deploy

An actor within the streamr ecosystem can deploy a new agreement contract by specifying which stream the agreement supports, setting the parameters of the smart contract providing initial funds, and providing any (unenforced) commitment to continue topping up the contract as payer under as long as a set of SLAs are met. For the purpose of this draft, it is assume that the contract is initialized with some quantity of funds $F$ such that $H>H_{\min}$ and that $\mathcal{B} = \emptyset$.

$$\hat{\Gamma}^+ = \hat{\Gamma} \cup \{i\}$$

This agreement will not be considered live until the minimum number of brokers has been established. During this transitory phase, no funds will change and the only consideration will be brokers joining or leaving.


#### Deploy Live

Once an agreement meets the criteria specified for live deployment, it may be deployed live in which case it will be governed by the [Streamr Broker Agreement Subsystem](https://hackmd.io/eDDH5oCsTJ2u-VgS0sZJOw) going forward. This agreement is removed from the set of agreements spinning up and placed within the live agreements. The parameters at the local level defined above will be transferred for initialization within this subsystem.

$$\hat{\Gamma}^+ = \hat{\Gamma} - \{i\}$$

$$\Gamma^+ = \Gamma \cup \{i\}$$

#### Cancel Deploy

In the case where the owner chooses to cancel a deployment, they will receive their funds back and the set of agreements spinning up will remove this agreement.

$$\hat{\Gamma}^+ = \hat{\Gamma} - \{i\}$$

### Broker Mechanisms

#### Join

A broker may join an agreement which is spinning up in which case the following will happen for broker i, agreement j. They will have to stake the minimum stake to do so.

$$\mathcal{B}_i^+ = \mathcal{B}_i \cup \{j\}$$


#### Leave

A broker may leave an agreement which is spinning up in which case the following will happen for broker i, agreement j.

$$\mathcal{B}_i^+ = \mathcal{B}_i - \{j\}$$
