# How layers become towers

> The rules the API applies when it turns a list of layers into towers.

You send a Program with Contracts holding Layers and Risks listing `contractRefs`. Layers may be in any order. The API decides how many towers a risk needs, where each layer sits, and what is left with the cedant. These are the rules it follows.

## One risk can have several towers

Layers that answer on different bases cannot be read on one scale, so they are drawn apart.

| Tower | Holds |
| --- | --- |
| `Tower` | Quota share, surplus, facultative, and excess of loss per claim. |
| `XOL Treaty - Per Event` | Excess of loss with `accumulateBasis: "EVT"`. |
| `XOL Treaty - Per Risk` | Excess of loss with `accumulateBasis: "RSK"`. |
| `XOL Treaty - Aggregate` | Excess of loss with `accumulateBasis: "AGR"`. |

An excess layer with no `accumulateBasis` is treated as per claim.

This program has a quota share, two per-event layers and an aggregate layer, so it draws as three towers:

Layers across every Contract a Risk lists are grouped by **effective Layer currency** (the Layer's override, else its Contract's currency) and the **Contract's line of business**. A risk with layers in two currencies gets a set of towers for each, with the currency added to the tower's name.

## Width is share, height is amount

Each block's width is the share of the risk it takes. Whatever is not ceded is drawn as **retention**, in grey. You do not send retention; the API works it out.

A Layer draws only its `firm order` and `signed` Lines, at their **signed share of whole**, falling back to Written share of whole when signing is unavailable. Signing comes from the same Engine function as [`/placements`](https://towers.vinsa.dev/docs/api/placements.md), using its default four decimal places. `/towers` has no `decimals` option. Each Line block's `share` reports that drawn share of whole, while `order` keeps the Layer's Order.

Indication, quoted and declined Lines are not drawn. The unplaced gap is cedant retention; if all Lines are non-firm, the entire Layer draws as retention. A Layer with **no Lines at all** still draws at its Order, which defaults to 100 for proportional Layers and to `participationShare`, else 100, for XOL. On proportional Layers, the drawn share multiplies the cession defined by `participationShare` and `retainedShare`.

In the whole viewpoint under `as supplied`, firm Lines draw at the caller's Signed shares of whole. If their total exceeds 100% of Order by more than `10^-4`, the Layer draws as one block at its Order width with `signed-share-overflow`. Within that tolerance, the Lines draw normally and the last Line span is clamped to the Layer slot. Under pro rata, when no Signed shares are available because To stand Lines exceed Order, overflowing firm Written shares use the same block with `written-share-overflow`. The block has no per-Line split (`reinsurer` and `lineStatus` are null). Otherwise the Lines draw at their Signed shares of whole, falling back to Written shares when signing is unavailable.

Shared Contracts draw at full size on each Risk; blocks report `sharedRiskCount` so callers can identify them. The drawing does not divide a shared Contract's capacity between Risks.

The [reinsurer viewpoint](https://towers.vinsa.dev/docs/api/viewpoints.md) splits each Layer slot into Our Lines, the rest of the Order and the cedant’s share.

## Surplus and facultative

Surplus treaties stack by their limits across the full width, on top of the quota share. A facultative placement with no limits of its own covers what is left above them, up to the risk's `sumInsured`.

## What an excess layer protects

`protection` on an excess-of-loss layer says what it sits over, which changes how wide it is drawn and where the treaties beneath it stop.

| `protection` | The layer protects |
| --- | --- |
| `ALL` | The whole risk, after the treaties beneath it. |
| `FGR` | The gross risk, alongside the quota share. |
| `RET` | The cedant's retention only. |

Here two layers protect only the retention, beside the quota share, under a layer that covers the whole risk:

## Layers with no upper limit

An unlimited layer is drawn running off the top of its tower with a dashed edge, and the axis reads "no limit" there.

## Layers that share a slot

Give layers the same `overlapGroup` when they are alternatives for the same position. They take one horizontal slot; the first is drawn and the others are returned with `isPrimary: false`.
