---
tags: Spec-Agreements
---
# Streamr Broker Agreements Math Spec
The current math specification covers the aggregate state of all broker agreements within Streamr. The subsystems referenced have their own math specifications referenced below:
[Streamr Broker Agreement Subsystem](https://hackmd.io/i8M8iFQLSIa9RbDn-d5Szg)
[Streamr Global Brokers Subsystem](https://hackmd.io/zSyD0CiWTrqUdA45NM4Z-g)
[Streamr Agreement Transition Subsystem](https://hackmd.io/fFrm3kKhRZab9nD006olfg)
## Global State
#### System State
| Symbol | Description | Domain |
| --------|------- | ----- |
| $\hat{\Gamma}$| Set of Agreements Spinning Up| |
| $\Gamma$| Set of Live Agreements| |
| $B$| Global Set of Brokers| |
## Mechanisms
### Global Broker Set Mechanisms
#### Join
The details of this action are covered within [Streamr Global Brokers Subsystem](https://hackmd.io/zSyD0CiWTrqUdA45NM4Z-g). In terms of the global state, the action expands the broker set.
$$ B^+ = B \cup \{i\}$$
#### Leave
The details of this action are covered within [Streamr Global Brokers Subsystem](https://hackmd.io/zSyD0CiWTrqUdA45NM4Z-g). In terms of the global state, the action reduces the broker set.
$$ B^+ = B - \{i\}$$
### 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.
All actions between deploy and deploy live are handled within [Streamr Agreement Transition Subsystem](https://hackmd.io/fFrm3kKhRZab9nD006olfg).
#### 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/i8M8iFQLSIa9RbDn-d5Szg) going forward. This agreement is removed from the set of agreements spinning up and placed within the live agreements.
$$\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\}$$
#### Cancel
In the event that the owner closes down a contract, each Broker gets back their stake, and recieves any unclaimed tokens allocated to their address as well an equal share of the remaining unallocated assets.
The effects of this action are covered within [Streamr Broker Agreement Subsystem](https://hackmd.io/i8M8iFQLSIa9RbDn-d5Szg).
The set of agreements will also have the agreement removed.
$$\Gamma^+ = \Gamma - \{i\}$$
#### Forced Cancel
There may conditions under which any address may trigger the cancel but these conditions should be indicative of a failure on the part of the payer. An example policy would be to allow forced cancel when $n < n_{\min}$ and $H<H_\min$, and possibly only if this is the case more multiple epochs.
The effects of this action are covered within [Streamr Broker Agreement Subsystem](https://hackmd.io/i8M8iFQLSIa9RbDn-d5Szg).
The set of agreements will also have the agreement removed.
$$\Gamma^+ = \Gamma - \{i\}$$