> ## Documentation Index
> Fetch the complete documentation index at: https://village-docs.villagelabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Step 2: Share Pool Calculation

> Loan-by-loan share release mechanics

## Overview

Calculate shares available for allocation from company contributions and loan releases.

## Loan-by-Loan Release

See [Simulation Core](/architecture/simulation-core#loan-by-loan-share-release) for detailed explanation.

```python theme={null}
# Release shares proportional to principal paid on each loan
for loan in esop_loans:
    release_pct = principal_payment / loan.original_principal
    shares_released = loan.original_suspense_shares * release_pct
    
    # Update loan suspense and trust unallocated pool
    loan.suspense_shares -= shares_released
    trust.unallocated_shares += shares_released
```

### Example: Two Loans

```python theme={null}
# Loan 1: Original $3M, suspense 30,000; principal paid this year: $300K
shares1 = 30_000 * (300_000 / 3_000_000)  # = 3,000

# Loan 2: Original $2M, suspense 15,000; principal paid this year: $200K
shares2 = 15_000 * (200_000 / 2_000_000)  # = 1,500

# Total pool from releases this year
share_pool_from_loans = shares1 + shares2  # = 4,500

# Trust unallocated pool increases by 4,500 shares
trust.unallocated_shares += share_pool_from_loans
```

<Note>
  Shares are released strictly from the paying loan's suspense account. This prevents cross-loan contamination and aligns with ERISA collateral rules.
</Note>
