Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ cargo test -p insurance_pool

# Useful flags
cargo test -p invoice_liquidity -- --nocapture # show stdout
cargo test -p invoice_liquidity test_name # filter by name
cargo test -p insurance_pool test_name # filter by name
```

Tests run on your native architecture via `soroban-sdk` test utilities — no WASM build needed.
Expand Down
30 changes: 30 additions & 0 deletions docs/storage-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,36 @@ Used for short-lived data that is cheap but can be cleared out automatically by
| `TotalVolumeEurc` | Persistent | `i128` | Global protocol stat |
| `TotalVolumeXlm` | Persistent | `i128` | Global protocol stat |

## 3b. InsurancePool Storage Layout

The `InsurancePool` contract (separate deployment) uses its own `DataKey`
subset. Storage-type semantics follow the same rules as above: `Instance`
keys live for the contract's lifetime and are cheaper; `Persistent` keys
survive upgrades but cost more to read/write.

| Variant | Storage Type | Stored Value | Purpose |
| ------- | ------------ | ------------ | ------- |
| `Admin` | Instance | `Address` | The liquidity contract (admin) |
| `Balance` | Instance | `i128` | Total pool balance (sum of premiums minus payouts) |
| `Coverage` | Instance | `u32` | Flat per-claim coverage cap |
| `Enrolled(Address)` | Persistent | `bool` | Enrollment flag per LP |
| `Premiums(Address)` | Persistent | `i128` | Cumulative premium paid per LP |
| `Claimed(u64)` | Persistent | `bool` | Whether a claim has been processed for an invoice |

### TTL settings for persistent keys

Persistent keys in Soroban require a TTL extension to avoid archival. The
ILN contracts set TTL bounds as follows:

- **Minimum TTL:** `1,000,000` ledgers
- **Maximum TTL:** `2,000,000` ledgers

These bounds apply to all `Persistent` `DataKey` variants above (including the
`InsurancePool` entries). Instance keys (`Admin`, `Balance`, `Coverage`) have
no separate TTL — they live for the contract instance's lifetime.

Source: `contracts/insurance_pool/src/lib.rs:49-64`.

## 4. Collision Prevention Strategy
The unification into the `DataKey` enum inherently prevents key collision:
- In Soroban SDK, custom enum variants serialize into `ScVal::Vec` where the first element is the string literal (Symbol) of the variant name.
Expand Down