Introducing Lambda’s DeFi PnL
In decentralized finance, one question stands above all others: "How much money am I actually making?" While this seems straightforward, the unique mechanics of DeFi—with its staking rewards, rebasing tokens, and other activities—make traditional profit-tracking methods inadequate.
In this guide, we're breaking down Lambda DeFi's inclusive approach to Profit and Loss (PnL) calculation, providing Wallets with the tools to help their users truly understand their portfolio performance.
The Foundation: What PnL Really Means in DeFi
At its core, PnL (Profit and Loss) is the total measure of your portfolio performance, expressed by a simple but powerful formula:
PnL = Unrealized Profit + Realized Profit
Let's dissect these components to understand what's actually happening with your assets:
Unrealized Profit Explained
Unrealized profit represents value changes in assets you still hold. This includes:
- Market value increases of tokens in your wallet
- Accumulated but unclaimed staking rewards
- Growth in rebasing tokens like stETH (where your token balance automatically increases)
- Any accrued yield that hasn't been harvested
The key characteristic: these profits exist "on paper" but haven't been captured in your wallet as separate assets yet.
Realized Profit Explained
Realized profit comes from completed transactions where you've locked in your gains or losses:
- Profits from selling tokens at a higher price than purchase
- Claimed staking rewards that now sit in your wallet
- Yield farming returns you've harvested
- Any asset you've unwrapped, swapped, or converted to another form
Both unrealized and realized profits can be negative when asset values decrease or when you sell at a loss.
A Real-World Example: The ETH Investment Scenario
To make this concrete, let's examine a simple scenario:
A user purchases 1 ETH for $2,000. Later, the market price reaches $2,500.
Scenario 1: A user HOLDS the ETH
- Unrealized profit: $500 (the price appreciation a user could capture if he sold)
- Realized profit: $0 (the user hasn't executed any action to lock in gains)
- Total PnL: $500 (entirely on paper)
Scenario 2: A User SELLS the ETH
- Unrealized profit: $0 (the user no longer holds the asset)
- Realized profit: $500 (the user has locked in the gain by selling)
- Total PnL: $500 (entirely captured)
This illustrates how the same total PnL can have completely different implications for a user's portfolio liquidity and risk exposure.
Two Perspectives: Base vs. Quote Currency Profit
Lambda's approach provides two crucial perspectives on a user's portfolio:
Base Currency Profit
This measures changes in the quantity of the actual crypto assets, answering the question: "How many more tokens do I have?"
For example:
- A user stakes 10 DOT and after 30 days has 10.5 DOT
- The base currency profit is 0.5 DOT (5% growth in the asset quantity)
This metric is particularly valuable in inflationary environments or when the user is focused on accumulating a specific asset.
Quote Currency Profit
This measures the monetary value of a user's holdings in the reference currency (often USD), answering: "How much more is my portfolio worth?"
For example:
- You stake 10 DOT worth $100 ($10 each)
- After 30 days, you have 10.5 DOT, but DOT's price dropped to $9
- Your quote currency value is now $94.50
- Your quote currency PnL is -$5.50, despite having more DOT
This perspective helps users to understand their actual financial position, accounting for both quantity and market price changes.
The Algorithm: How Lambda Actually Calculates User PnL
Lambda's calculation methodology is specifically designed to capture the nuances of DeFi portfolio performance:
1. Interval-Based Approach
Rather than looking at a portfolio in a single continuous period, we break it down into meaningful intervals:
- User Action Intervals: Created whenever a user performs actions that change their portfolio structure:
- Buying or selling assets
- Staking or unstaking
- Adding liquidity or withdrawing
- Claiming rewards
- Receiving transfers from others
- Regular Time Intervals: For longer periods, we also add standard time divisions (weekly for 1-month reports, monthly for 1-year reports) to capture market movements between user actions
This approach ensures we catch both active decisions and passive market effects.
2. Comprehensive Data Collection
For each interval, we record:
- Starting and ending token balances
- Starting and ending token prices
- Any external influences (network rewards, rebases, etc.)
3. Precise PnL Calculation Formula
For each interval, we calculate:
Interval PnL = (End Price × End Balance) - (Start Price × Start Balance)
This captures both price effects and quantity changes in a single metric.
4. Results Aggregation
We then aggregate all interval results to produce:
- Overall period PnL
- Time-segmented PnL (monthly, quarterly, etc.)
- Performance visualizations
The stToken Example: Seeing Lambda's PnL Calculation in Action
Let's walk through a detailed example with a staking token that automatically increases in balance over time:
Timeline:
- January 3, 2023: Initial purchase of 1 stToken at $200
- February 5, 2024: Received 1.5 additional stTokens from a friend
- December 10, 2024: Unwrapped 0.5 stToken
- December 31, 2024: PnL report requested
Step 1: Dividing into Intervals
Lambda divides this into multiple intervals:
- 12 monthly points (Jan 2023 through Dec 2024)
- 4 additional points for user activities (purchase, top-up, withdrawal, current time)
This creates intervals like:
- Jan 3 - Feb 1, 2023
- Feb 1 - Feb 5, 2023
- Feb 5 - Mar 1, 2023
- ...and so on
Step 2: Tracking Data Points
For each interval, we record:
- Beginning and ending token balances
- Beginning and ending token prices
Step 3: Calculating Interval PnL
For each period, the calculation works like this:
Interval | Token Balance Change | Token Price Change | Calculation | PnL ($) |
Jan 3 - Feb 1 | 1.0 → 1.1 | $200 → $180 | (180×1.1) - (200×1.0) | -$2.00 |
Feb 1 - Feb 5 | 1.1 → 1.12 | $180 → $185 | (185×1.12) - (180×1.1) | +$9.20 |
Feb 5 - Mar 1 | 2.62 → 2.7 | $185 → $175 | (175×2.7) - (185×2.62) | -$12.00 |
Mar 1 - Apr 1 | 2.7 → 2.8 | $175 → $175 | (175×2.di8) - (175×2.7) | +$17.50 |
... | ... | ... | ... | ... |
Dec 1 - Dec 10 | 3.1 → 3.3 | $175 → $175 | (175×3.3) - (175×3.1) | +$35.00 |
Dec 10 - Dec 31 | 2.8 → 2.88 | $175 → $180 | (180×2.88) - (175×2.8) | +$28.40 |
Step 4: Aggregating Results
Adding all interval PnL values gives your total one-year PnL: $76.10
This detailed breakdown shows exactly how a user's position evolved through price changes, balance growth, additional deposits, and partial withdrawals.
Understanding Specific DeFi Scenarios
Lambda's PnL calculation handles various DeFi-specific situations:
Rebasing Tokens (like stETH)
With tokens that automatically increase in quantity:
- Balance growth is captured within intervals
- This growth is counted as profit, even without explicit claiming
Yield Farming
For yield farming positions:
- Unclaimed rewards are tracked as unrealized profit
- Claimed rewards become realized profit
- Compounding effects are captured through balance increases
Liquidity Provision
For LP positions:
- Impermanent loss is factored into the price component
- Earned fees are captured as balance increases
- Token ratio shifts are handled through the balance measurement
How Lambda's PnL Offers Unique Revenue Opportunities for Wallets
Understanding true DeFi performance goes beyond simple curiosity—it directly translates to strategic business advantages for wallet applications.
Within the user base, DeFi users represent the most valuable cohort, driving the majority of profitable transactions. Lambda's PnL solution helps retain these high-value users through a genuine market differentiator—no wallet in the ecosystem currently offers true DeFi return tracking or distinguishes rewards from regular transfers.
This retention advantage works on two crucial levels:
- Experienced DeFi users stay engaged when they can finally track their actual portfolio performance, keeping your most profitable customers within your ecosystem.
- New users gain the confidence to explore DeFi when presented with familiar performance metrics that mirror traditional Web2 investment platforms, accelerating their journey toward becoming power users.
By implementing Lambda's PnL tracking, wallet providers create a compelling reason for users to stay within their ecosystem rather than switching between applications or abandoning DeFi altogether when faced with performance uncertainty.
Start Tracking Your True DeFi Performance Today
To start tracking your true DeFi performance, you can request access to query the PnL data with Lambda.
Lambda's sophisticated yet intuitive PnL calculation gives you the data-backed insights needed to increase your revenue.
No more spreadsheets, manual calculations, or incomplete metrics—just clear, accurate performance tracking that captures all the nuances of your DeFi portfolio.
Corner Cases and FAQ
Q: Can I evaluate PnL for positions I've already closed?
A: Yes. Lambda analyzes historical data on asset acquisition and disposal prices, allowing for retroactive PnL calculation even for positions that no longer exist in your portfolio.
Q: How does Lambda account for swaps and bridging in PnL calculations?
A: Swaps and bridging are treated as events that trigger the closing of one position and opening of another. For example, swapping ETH to USDT closes your ETH position and opens a USDT position, with each having its own PnL tracking.
For immediate losses or gains during swaps (like slippage costs), Lambda will introduce a transaction-level PnL feature in Q2 that captures these effects separately from position-level PnL.
Q: How does Lambda handle external transfers?
A: Third-party transfers (like receiving tokens from a friend) are treated similarly to manual top-ups—they create a new interval but don't reset your entire position history.
Q: How does the system handle price volatility in both base and quote currencies?
A:
- USD as a base currency is stable (always = $1)
- For crypto assets, we use historical price feeds that capture all volatility
- Calculations are performed at interval boundaries to capture significant price movements
Q: How does Lambda handle withdrawals and top-ups?
A:
- Full withdrawals mark the end of a position
- Partial withdrawals create a new interval but maintain position continuity
- Top-ups (additions to existing positions) create new intervals with the combined balance going forward
Want to experience the power of Lambda's PnL tracking for yourself? Contact our team today to learn how our staking solutions can optimize your crypto portfolio while providing unparalleled transparency into your portfolio performance.
Website: https://lambda.p2p.org/
The information provided above is for informational purposes only and should not be construed as, or relied upon as, investment, financial, or any other type of professional advice. P2P.org or any associated parties do not offer any form of advisory services, and nothing shared here should be considered as a recommendation or endorsement for any financial decisions. P2P.org are not responsible for any decisions made based on the information provided. You are encouraged to consult with a qualified financial advisor or professional before making any investment or financial decisions.