Full PnL Documentation
Introduction
Full PnL is a revenue-sharing mechanism designed to calculate the monthly distribution between Sky (capital provider) and Prime Agents (allocation operators). The system uses segmented time-series calculations to accurately attribute returns across discrete periods, ensuring precise revenue distribution based on actual performance.
Core Revenue Principles
- Base Rate: Sky charges 5.05% annually for capital provided to Prime Agents
- Performance Split: Prime Agents retain excess returns above base rate, or bear shortfalls when underperforming
This dual-party model creates aligned incentives where Prime Agents benefit from successful capital deployment while Sky receives consistent returns for providing liquidity. The segmented approach ensures accuracy when asset balances change throughout the month.
How It Works
The Full PnL system tracks hourly snapshots of Prime Agent asset holdings across multiple blockchains and calculates revenue splits using compound daily returns. Each month is divided into segments based on snapshot boundaries, with revenue calculated separately for each segment before aggregation.
Supported Blockchains
The system operates across major blockchain networks:
- Ethereum
- Base
- Arbitrum
- Optimism
- Unichain
- Avalanche
- Plume
Monitored Prime Agents
Each Prime Agent operates as an independent allocation system:
Current Prime Agents:
- Spark
- Grove
- Keel
- Additional Prime Agents added as the ecosystem expands
Prime Agent Structure:
- Unique wallet addresses per blockchain
- Independent asset catalogs and yield tracking
- Individual PnL calculations and settlement
Monthly Settlement Process
Settlement occurs at calendar month boundaries:
- System captures final asset values and yields at month end
- PnL calculation computes Sky and Prime Agent revenue using segmented timeline
- Results determine on-chain payment flows between parties
- System state reflects accumulated positions
System State Components
The system maintains a global financial position snapshot:
- AUM (Assets Under Management): Total value across all chains
- Debt: Amount borrowed from Sky DAO
- Non-Accumulated Profit: Difference between AUM and Debt
Algorithm Details
Segmented Timeline Processing
The algorithm divides each month into discrete segments based on hourly asset snapshots. This approach captures balance changes throughout the period for accurate revenue attribution.
Segment Creation:
- Each hourly snapshot creates a segment boundary
- Asset value remains constant within each segment
- Segments have variable duration based on snapshot timing
- Revenue calculated independently per segment
Compound Daily Return Formula:
Daily Return = (1 + Period Return)^(1/Period Days) - 1
Where:
- Period Return is the asset's return over the entire measurement period
- Period Days is the number of days in the period
- The result is the equivalent daily compound rate
Segment Revenue Calculation:
For each segment, the system calculates:
- Segment duration in days
- Segment return using daily compound rate
- Actual revenue from asset value and segment return
- Base rate charge for the segment duration
- Revenue split based on asset category
Asset Categories and Revenue Attribution
Different asset types require specific revenue-sharing rules based on their risk profiles and contractual agreements.
Standard Assets
Standard assets represent the default revenue-sharing arrangement where Prime Agents bear full performance responsibility.
Revenue Split:
When performance meets or exceeds base rate:
- Sky Revenue = Base Rate Charge
- Prime Agent Revenue = Actual Revenue - Base Rate Charge
When performance falls below base rate:
- Sky Revenue = Base Rate Charge
- Prime Agent Revenue = Actual Revenue - Base Rate Charge (negative)
The negative Prime Agent revenue represents payment to Sky for underperformance.
Protected Assets (Sky Direct Exposure)
Protected assets shield Prime Agents from negative revenue when underperforming, reflecting situations where Sky retains more direct exposure.
Revenue Split:
- Sky Revenue = Base Rate Charge
- Prime Agent Revenue = Maximum of zero or (Actual Revenue - Base Rate Charge)
Prime Agent revenue cannot go negative for these assets.
Strategic Assets
Strategic assets always charge the full base rate regardless of performance, with Prime Agents bearing complete downside risk.
Revenue Split:
- Sky Revenue = Base Rate Charge (always)
- Prime Agent Revenue = Actual Revenue - Base Rate Charge
This category includes PYUSD allocations and SparkLend USDT positions.
Real World Assets
Real world assets generate returns through off-chain mechanisms not visible on blockchain. Sky receives 100% of the yield or returns from these positions.
Revenue Split:
- Sky Revenue = 100% of yield/returns generated
- Prime Agent Revenue = 0
BUIDL (BlackRock's tokenized fund) exemplifies this category where dividends accrue off-chain.
USDS Savings Products
SparkLend USDS positions use the Sky Savings Rate (SSR) instead of the standard base rate, reflecting the different economics of USDS lending.
SSR Charge = Asset Value × (SSR / 365) × Segment Duration
Where:
- SSR is the Sky Savings Rate as a decimal
- Segment Duration is measured in days
Revenue Split When Outperforming SSR:
- Sky Revenue = SSR Charge
- Prime Agent Revenue = Actual Revenue - SSR Charge
Revenue Split When Underperforming SSR:
Proportional adjustment applies:
- Sky Revenue = Actual Revenue × (SSR / Actual APY)
- Prime Agent Revenue = Actual Revenue - Sky Revenue
The proportional ratio ensures Sky receives its share when full SSR charge cannot be met.
Yield Measurement Methods
Different token types require specific approaches to measure on-chain yields:
ERC-4626 Vaults:
- Read exchange rate growth between period blocks
- Examples: Morpho, Maple, Fluid vaults
Aave/Spark Lending:
- Track liquidity index with virtual projection
- Examples: Aave, SparkLend positions
Centrifuge RWA:
- Monitor price per share from vault contracts
BlackRock BUIDL:
- Returns 0% on-chain (off-chain dividend distribution)
Superstate:
- Measure balance growth (rebasing token)
Ethena:
- ERC-4626 for sUSDe, opportunity cost for USDe
Curve LP:
- Track virtual price growth
Pricing Methodology
The system applies specific pricing rules to ensure consistent valuation:
Stablecoin Pricing:
- USDS, USDC, USDT, DAI, sUSDS: Fixed at $1.00
- Prevents mark-to-market volatility on stable positions
Yield Wrapper Pricing:
- Market price or derived from exchange rate
- aTokens priced from underlying asset
- Centrifuge derived from price per share
Fallback Logic:
- Check for forced price override in catalog
- Query external price feeds if not overridden
- Derive from underlying for wrapper tokens
- Default to $1 for flagged stable assets
Tech Stack
Core Technologies
Backend Framework:
- Next.js API routes for endpoint implementation
- TypeScript for type safety and developer experience
- Node.js runtime environment
Database:
- PostgreSQL for persistent storage
- Kysely query builder for type-safe SQL operations
- Supabase as managed PostgreSQL provider
Blockchain Integration:
- Alchemy for RPC access across multiple chains
- Ethers.js for contract interactions
- Custom ABIs for vault and token interfaces
External APIs:
- Morpho API for historical vault APY
- Price feed APIs for token valuation
- Blockchain explorers for verification
Data Processing Pipeline
Hourly Collection:
- Cron jobs scheduled per blockchain
- RPC calls to fetch current balances
- Batch processing for efficiency
Yield Measurement:
- Daily scheduled tasks at 2:13 AM UTC
- Historical block queries for rate changes
- Fallback calculations when APIs unavailable
PnL Calculation:
- On-demand endpoint processing
- Parallel segment calculations
- Aggregation and validation layers
Data Storage Architecture
Time-Series Data
The system maintains comprehensive historical records:
Asset Snapshots:
- Hourly records of Prime Agent holdings across all chains
- Balance quantities, USD values, and prices at each timestamp
- Metadata including blockchain, protocol, and allocation type
Yield Measurements:
- Historical yield data for tracked assets
- Annualized yields and raw period returns
- Measurement methodology and quality indicators
Asset Configuration:
- Rules defining special handling per asset
- Revenue attribution categories and exception flags
- Pricing overrides and measurement parameters
Data Retention Strategy
Active Data:
- Current month snapshots in hot storage
- Recent yield measurements cached
- Configuration actively loaded
Historical Data:
- Previous months archived but queryable
- Compressed storage for older periods
- Audit trail maintained indefinitely
Raw Data Sources
Blockchain Data via Alchemy
Balance Queries:
- Direct RPC calls to blockchain nodes
- Token balance methods for ERC-20 assets
- Vault share queries for yield-bearing tokens
Exchange Rate Data:
- Vault contract exchange rates
- Liquidity indices from lending protocols
- Price per share from RWA contracts
Block Information:
- Timestamps for precise timing
- Block numbers for historical queries
- Chain state at specific points
External API Sources
Morpho API:
- Time-weighted APY calculations
- Vault performance metrics
- Capital allocation history
Price Feeds:
- Market prices for non-stable assets
- Multiple sources for validation
- Fallback providers for resilience
Protocol APIs:
- Aave subgraph for lending data
- Curve API for LP token metrics
- Centrifuge API for RWA valuations
Event Collection Process
Automated Data Pipeline
The system operates through three coordinated processes:
Hourly Snapshots:
- Capture current asset balances via blockchain RPC
- Store snapshots with timestamps and values
- Run at :14 (Ethereum), :17 (Base), :19 (other chains)
Daily Yield Measurement:
- Measure historical yields at 2:13 AM UTC
- Calculate returns for last complete month
- Store samples for all unique token contracts
On-Demand PnL Calculation:
- Load snapshots to build segmented timeline
- Apply compound daily returns per segment
- Aggregate results by asset and category
- Return comprehensive revenue attribution
Data Flow Architecture
The pipeline follows this sequence:
- Asset catalog defines tracked tokens
- Hourly snapshots capture balance changes
- Daily measurements calculate historical yields
- PnL endpoint combines data for revenue calculation
Historical data accumulates automatically through scheduled processes. Manual backfill only required for periods before automation or failed measurements.
Validation and Quality Checks
Revenue Validation
The system performs multiple checks to ensure calculation accuracy:
Sky Revenue Validation:
- Must always be non-negative
- Violations indicate calculation error
Prime Agent Revenue Validation:
- Standard/Strategic: Can be negative when underperforming
- Protected: Must be non-negative (floored at zero)
- RWA: Always exactly zero
- USDS Savings: Follows proportional adjustment rules
Aggregation Consistency:
- Individual segment revenues must sum to totals
- Tolerance of 0.01% for rounding differences
Data Quality Monitoring
Balance Reasonableness:
- Flag large changes (>100% in one hour)
- Reject negative balances as impossible
- Verify creation blocks for new assets
Price Reasonableness:
- Stablecoins within $0.98-$1.02 range
- Yield wrappers >= underlying price
- Flag sudden changes >50% per hour
Yield Range Validation:
- Reject yields below -100% as errors
- Flag yields above 1000% APY for review
- Compare with previous month for consistency
Manual Cross-Checks
Critical periods require additional verification:
- Compare AUM against external audit snapshots
- Verify system state equation (AUM - Debt = Non-accumulated profit)
- Spot-check large assets using formulas
- Validate segment boundaries and durations
- Confirm special asset processing (PYUSD, BUIDL)
Important Considerations
Timing and Data Freshness
Optimal Calculation Timing:
Results are most accurate after:
- Month has completely ended
- Final snapshots collected (within 1 hour)
- Yield measurements completed (24-48 hours)
Early calculations provide estimates but should not be used for settlement.
Asset Changes Mid-Period
The segmented approach automatically handles:
- New assets contributing from first snapshot
- Removed assets contributing until last snapshot
- Balance changes using segment start values
Special Period Handling
Partial Periods:
- Can calculate mid-month estimates
- Results require careful interpretation
- May lack complete yield data
Historical Recalculation:
- Ensure snapshot data available
- Verify yield measurements exist
- Document reasons and corrections
Multi-Chain Considerations
Chain Aggregation:
- Each chain collected independently
- System state always global (all chains)
- Chain filtering affects revenue but not state
Chain-Specific Timing:
- Different block times affect measurements
- Archive data availability varies
- Collection schedules staggered by chain
Accuracy Benefits
The segmented calculation provides precision for:
- Assets with significant balance changes
- High APY positions requiring exact attribution
- Volatile yield environments
- Regulatory and audit requirements
Performance scales with portfolio size (O(n × m) where n = assets, m = segments). Large portfolios benefit from parallel processing and query optimization.
Business Logic Summary
Revenue Distribution Model
The Full PnL system implements a sophisticated revenue-sharing model between Sky and Prime Agents:
Sky's Position:
- Provides capital to Prime Agents
- Receives base rate (5.05% APY) on standard allocations
- Receives SSR on USDS positions
- Protected from losses on protected assets
- Receives 100% of RWA yields
Prime Agent's Position:
- Deploys capital across DeFi protocols
- Retains profits above base rate
- Bears losses when underperforming (except protected assets)
- Manages operational aspects of allocations
- Optimizes for yield while managing risk
Settlement Mechanics
Monthly settlement follows a structured process:
- Data Collection: System gathers all asset snapshots and yield data
- Calculation: Segmented PnL algorithm processes each asset
- Aggregation: Results combined by category and Prime Agent
- Validation: Quality checks ensure accuracy
- Settlement: Final amounts determine payment flows
Economic Incentives
The model creates aligned incentives:
- Prime Agents motivated to maximize returns
- Sky receives predictable base returns
- Protection mechanisms prevent systemic risks
- Transparent calculations enable trust
- Monthly cycles provide regular reconciliation
Risk Management
Multiple layers of risk management:
Asset Categorization:
- Different rules for different risk profiles
- Protection for Sky on certain exposures
- Clear accountability for performance
Validation Layers:
- Automated checks prevent calculation errors
- Manual reviews for critical periods
- Historical comparisons detect anomalies
Operational Safeguards:
- Hourly snapshots prevent data loss
- Multiple data sources provide redundancy
- Audit trails enable investigation