Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cab98ae
build: add Makefile with build, test, lint, deploy, and wasm-size tar…
nonsobethel0-dev May 24, 2026
1cb8247
docs: add ARCHITECTURE.md covering contract map, data flow, oracle ke…
nonsobethel0-dev May 24, 2026
b7f2891
chore: add version 0.2.0, authors, description, keywords, and license…
nonsobethel0-dev May 25, 2026
d318797
feat(risk-pool): add types — LpPosition, CapitalLock, PoolStats, Pool…
nonsobethel0-dev May 25, 2026
4a82e43
feat(risk-pool): implement initialize, deposit with proportional shar…
nonsobethel0-dev May 25, 2026
cf3323c
test(risk-pool): add deposit, withdraw, yield, lock, and pause test s…
nonsobethel0-dev May 26, 2026
47c8070
feat(governance-dao): add types — Proposal, VoteRecord, DaoConfig, Pr…
nonsobethel0-dev May 27, 2026
e7692d3
feat(governance-dao): implement initialize, create_proposal, vote, fi…
nonsobethel0-dev May 27, 2026
49df544
test(governance-dao): add proposal lifecycle, voting, quorum, and can…
nonsobethel0-dev May 28, 2026
fcfe901
feat(oracle-verifier): add verify_trigger_fresh for staleness check a…
nonsobethel0-dev May 29, 2026
28a8b57
feat(policy-engine): add emergency_pause and emergency_resume admin c…
nonsobethel0-dev May 29, 2026
d010a14
feat(claims-processor): add batch_auto_process to settle multiple cla…
nonsobethel0-dev May 30, 2026
604d9bf
ci: add GitHub Actions workflow for build, test, clippy, and WASM siz…
nonsobethel0-dev May 31, 2026
5736428
scripts: add deploy_mainnet.sh with dual-confirmation safety gate
nonsobethel0-dev Jun 1, 2026
8a7215a
scripts: add create_products.sh to seed the four protocol insurance p…
nonsobethel0-dev Jun 1, 2026
3f175f1
scripts: add register_oracle.sh for onboarding oracle nodes to Oracle…
nonsobethel0-dev Jun 2, 2026
ec985b2
chore: add clippy.toml with cognitive complexity threshold and test u…
nonsobethel0-dev Jun 2, 2026
da9d12f
chore: add [profile.dev] to workspace Cargo.toml for faster local ite…
nonsobethel0-dev Jun 3, 2026
149bf7b
feat(oracle-verifier): add OracleHealth type for oracle monitoring an…
nonsobethel0-dev Jun 3, 2026
7d455a7
feat(policy-engine): add ProductStats type for on-chain product analy…
nonsobethel0-dev Jun 4, 2026
5780992
test(oracle-verifier): add staleness rejection and batch_submit_data …
nonsobethel0-dev Jun 4, 2026
dddb5d4
test(claims-processor): add integration tests for batch_auto_process …
nonsobethel0-dev Jun 5, 2026
cbc26d6
docs: add SECURITY.md with vulnerability disclosure policy and bug bo…
nonsobethel0-dev Jun 5, 2026
bbae977
docs: add CONTRIBUTING.md with dev setup, conventions, and PR checklist
nonsobethel0-dev Jun 6, 2026
9b03c9c
feat(risk-pool): add get_lp_count and get_available_liquidity query f…
nonsobethel0-dev Jun 6, 2026
92ecb14
test(risk-pool): add multi-LP proportional yield, LP count, and avail…
nonsobethel0-dev Jun 7, 2026
7c06370
test(governance-dao): add abstain vote, config update, double-execute…
nonsobethel0-dev Jun 7, 2026
12d55d1
test(policy-engine): add emergency pause, product lifecycle, and canc…
nonsobethel0-dev Jun 8, 2026
8105b2e
scripts: add check_balances.sh for quick USDC balance health check
nonsobethel0-dev Jun 8, 2026
3fc616d
scripts: add submit_oracle_data.sh for manual oracle data submission
nonsobethel0-dev Jun 9, 2026
4b6f54a
ci: add release workflow to publish WASM artifacts on version tags
nonsobethel0-dev Jun 9, 2026
06573a8
test(oracle-verifier): add 3-oracle median, overwrite, deactivation, …
nonsobethel0-dev Jun 10, 2026
f17be48
docs: add oracle-key-format.md with 9-char Symbol encoding convention…
nonsobethel0-dev Jun 10, 2026
4647fa1
docs: add economics.md covering premium flow, LP share mechanics, and…
nonsobethel0-dev Jun 11, 2026
fe741a8
docs: add deployment-checklist.md covering pre-deploy, testnet valida…
nonsobethel0-dev Jun 11, 2026
b36185d
chore: add workspace metadata with protocol version and audit status …
nonsobethel0-dev Jun 12, 2026
6ac8a86
test(risk-pool): add edge case tests — zero yield, full round-trip, 1…
nonsobethel0-dev Jun 12, 2026
a07f302
build: expand Makefile with pre-release, deploy-mainnet, submit-oracl…
nonsobethel0-dev Jun 13, 2026
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
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release WASM Artifacts

on:
push:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
build-and-release:
name: Build & Release WASM
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32v1-none

- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contracts/target
key: ${{ runner.os }}-cargo-${{ hashFiles('contracts/Cargo.lock') }}

- name: Run tests
working-directory: contracts
run: cargo test --quiet

- name: Build optimized WASM
working-directory: contracts
run: cargo build --target wasm32v1-none --release --quiet

- name: Collect artifacts
run: |
mkdir -p dist
cp contracts/target/wasm32v1-none/release/*.wasm dist/
ls -lh dist/

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.wasm
generate_release_notes: true
body: |
## Parashield Protocol ${{ github.ref_name }}

### Contracts
- `parashield_oracle_verifier.wasm` — Oracle data aggregation
- `parashield_policy_engine.wasm` — Insurance product and policy management
- `parashield_claims_processor.wasm` — Automated claim evaluation
- `parashield_risk_pool.wasm` — LP liquidity pools with yield distribution
- `parashield_governance_dao.wasm` — Token-weighted protocol governance

### Verification
Verify WASM hash against the published checksum before deploying.
84 changes: 84 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
push:
branches: [main, "feat/**"]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
build-and-test:
name: Build & Test (Soroban)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32v1-none

- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contracts/target
key: ${{ runner.os }}-cargo-${{ hashFiles('contracts/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Run tests
working-directory: contracts
run: cargo test --quiet

- name: Build WASM targets
working-directory: contracts
run: cargo build --target wasm32v1-none --release --quiet

- name: Run Clippy
working-directory: contracts
run: cargo clippy --all-targets -- -D warnings

wasm-size:
name: WASM Binary Size Report
runs-on: ubuntu-latest
needs: build-and-test

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32v1-none

- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contracts/target
key: ${{ runner.os }}-cargo-${{ hashFiles('contracts/Cargo.lock') }}

- name: Build WASM
working-directory: contracts
run: cargo build --target wasm32v1-none --release --quiet

- name: Report binary sizes
working-directory: contracts
run: |
echo "| Contract | Size (KB) |"
echo "|----------|-----------|"
for f in target/wasm32v1-none/release/*.wasm; do
name=$(basename "$f" .wasm)
size=$(du -k "$f" | cut -f1)
echo "| $name | ${size} |"
done
127 changes: 127 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Parashield Protocol Architecture

## Overview

Parashield is a decentralised parametric insurance protocol built on Stellar Soroban.
Unlike traditional insurance, claims are settled automatically by smart contracts
when a real-world trigger condition is confirmed by an oracle network.
No adjuster. No form. No delay.

## Contract Map

```
┌──────────────────────────────────────────────────────────┐
│ User / DApp │
└────────────────────┬──────────────────────────────────────┘
│ buy_policy / submit_claim
┌──────────────────────────────────────────────────────────┐
│ Policy Engine (policy-engine) │
│ - Products catalogue (admin-defined) │
│ - Policy lifecycle: Active → Claimed / Expired │
│ - Holds USDC escrow until payout or expiry │
└──────┬──────────────────────────────────┬────────────────┘
│ get_policy / pay_claim / │ get_contract_balance
│ expire_policy │
▼ ▼
┌─────────────────────┐ ┌─────────────────────────┐
│ Claims Processor │ │ Risk Pool │
│ (claims-processor) │ │ (risk-pool) │
│ │ │ - LP deposits USDC │
│ - Evaluates oracle │ │ - Pool tokens (shares) │
│ - Calls pay_claim │ │ - Yield from premiums │
│ or expire_policy │ │ - Locks coverage cap. │
└──────┬──────────────┘ └─────────────────────────┘
│ verify_trigger
┌──────────────────────────────────────────────────────────┐
│ Oracle Verifier (oracle-verifier) │
│ - Multiple oracles submit signed observations │
│ - Confidence-weighted median aggregation │
│ - verify_trigger: returns bool for trigger condition │
└──────────────────────────────────────────────────────────┘

Admin / Token Holders
┌────────────────────┐
│ Governance DAO │
│ (governance-dao) │
│ - Proposals │
│ - Token voting │
│ - Protocol params │
└────────────────────┘
```

## Data Flow: Parametric Payout

```
1. Admin creates InsuranceProduct (oracle key, threshold, comparison)
2. User calls buy_policy(product_id, coverage_amount, duration_days, oracle_key)
- Premium = coverage * premium_rate_bps / 10_000
- USDC premium transferred from user to Policy Engine
- Policy record created with status = Active
3. Oracle(s) submit data via oracle-verifier.submit_data() periodically
4. Keeper calls claims-processor.auto_process(policy_id)
- Claims Processor calls oracle-verifier.verify_trigger(condition)
- If trigger met: Policy Engine.pay_claim() → USDC → policyholder
- If trigger not met AND policy expired: Policy Engine.expire_policy()
```

## Fixed-Point Math

All monetary values use 7-decimal fixed point matching Stellar's native precision:

| Display value | On-chain representation |
|---------------|------------------------|
| 1 USDC | 10_000_000 |
| 50.5 mm rain | 505_000_000 |
| 120 min delay | 1_200_000_000 |

## Oracle Key Format

Oracle keys follow a structured naming convention (max 9 chars = Soroban Symbol):

| Data type | Key format | Example |
|-------------|-------------------------------|-------------|
| Rainfall | `{loc}{yyyymm}` | `kis2606` |
| Temperature | `tmp{loc}{mm}` | `tmpkis06` |
| Flight | `fl{flight}{dd}` | `flkq10015` |
| Wind speed | `wnd{loc}{mm}` | `wndmom06` |
| DeFi event | `defi{proto}` | `defiave` |

## Risk Pool Economics (v2)

```
Premium flow:
80% → Risk Pool (LP yield)
10% → Protocol Treasury (governance-controlled)
10% → Backstop Fund (solvency reserve)

Utilization rate = total_active_coverage / total_deposited_liquidity

Target APY ranges:
Low-risk pools (crop, flight): 8–15%
Medium-risk (disaster): 15–25%
High-risk (DeFi exploit): 25–40%
```

## Governance DAO (v2)

SHIELD token holders govern protocol parameters:

- Add / remove insurance products
- Adjust premium rates and trigger thresholds
- Register / deregister oracle sources
- Allocate protocol treasury funds
- Emergency pause individual contracts

**Proposal lifecycle:** Draft → Active (7-day voting) → Passed (≥10% quorum, simple majority) → Executed (2-day timelock)

## Security Notes

- Admin keys should transition to Governance DAO after protocol launch
- Oracle submissions are bounded by registered oracle set (not open)
- Policy Engine holds USDC in escrow: no admin withdrawal function
- Claims Processor is the only address authorized to call `pay_claim` / `expire_policy`
- All monetary arithmetic uses checked arithmetic (Soroban default with overflow-checks = true)
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to Parashield Contracts

## Setup

```bash
# Install Rust + Soroban target
rustup target add wasm32v1-none

# Build
make build

# Test
make test

# Lint
make lint
```

## Conventions

- All storage keys use `#[contracttype]` enums.
- Monetary values use 7-decimal fixed-point `i128` (1 USDC = 10_000_000).
- All public functions that modify state require `caller.require_auth()`.
- Errors use `#[contracterror]` with explicit `#[repr(u32)]` codes.
- Tests live in `src/test.rs` (unit) and `src/test_integration.rs` (cross-contract).

## PR Checklist

- [ ] `make test` passes
- [ ] `make lint` passes with zero warnings
- [ ] New public functions have a short doc comment explaining the invariants
- [ ] Error codes do not collide with existing ones
- [ ] Persistent storage keys are documented in the StorageKey enum comment

## Adding a New Contract

1. `cargo new --lib contracts/<name>`
2. Add to `contracts/Cargo.toml` `[workspace.members]`
3. Set `crate-type = ["cdylib", "rlib"]` in the crate's `Cargo.toml`
4. Add a `testutils` feature that enables `soroban-sdk/testutils`
5. Write at least 5 unit tests covering init, happy path, and error paths
6. Update `ARCHITECTURE.md` with the new contract's role

## Commit Messages

Follow [Conventional Commits](https://www.conventionalcommits.org/):

```
feat(oracle-verifier): add batch_submit_data
fix(risk-pool): guard against zero deposit edge case
test(claims-processor): add dispute resolution tests
chore: update soroban-sdk to 22.1
```
Loading
Loading