Prompt

How do I set up on-chain accounting software for reconciling LP positions, staking rewards, and wallet balances?

Cryptocurrency & Web3 / DeFi2 observationsLast seen Nov 24, 2026

Latest observation

Nov 24, 2026OpenAI APIWeb search: off

To set up on-chain accounting software for reconciling LP positions, staking rewards, and wallet balances, you want a system that can do three things reliably:

  1. Ingest on-chain data
  2. Classify every transaction and position change
  3. Map it into accounting records that reconcile to wallet and protocol balances

Here’s a practical setup approach.


1) Define the scope first

Decide which chains, protocols, and assets you need to support.

Track at minimum:

  • Wallet balances
    • Native coins
    • ERC-20 / SPL / other token balances
  • LP positions
    • Uniswap-style AMM LP tokens
    • V3 concentrated liquidity positions
    • Vault shares / yield-bearing LP wrappers
  • Staking rewards
    • Auto-compounding or claimable rewards
    • Emissions paid in native token or reward token
  • Transfers
    • Deposits, withdrawals, bridges
  • Fees and yield
    • Trading fees, protocol rewards, incentive distributions

Decide accounting basis:

  • Cash basis: recognize income when received/claimed
  • Accrual basis: recognize when earned
  • Fair market value (FMV) at transaction time

For most on-chain accounting, FMV + lot tracking is the most useful.


2) Choose your data sources

You need both on-chain raw data and pricing data.

On-chain sources

Use one or more of:

  • RPC / archive nodes for direct chain reads
  • Indexers like:
    • The Graph
    • Covalent
    • Alchemy
    • Moralis
    • Bitquery
    • Subsquid
  • Protocol subgraphs / APIs
    • Uniswap, Curve, Aave, Lido, etc.

Pricing sources

For valuation and reconciliation:

  • CoinGecko / CoinMarketCap
  • Chainlink price feeds
  • DEX TWAP
  • Internal pricing oracle if you need auditability

Why you need both

On-chain data tells you:

  • what happened

Pricing data tells you:

  • what it was worth in reporting currency at that time

3) Build a canonical transaction model

Normalize all activity into a common schema.

Suggested fields

  • chain_id
  • wallet_address
  • tx_hash
  • block_number
  • timestamp
  • event_type
  • asset_in
  • asset_out
  • amount_in
  • amount_out
  • protocol
  • counterparty
  • position_id
  • usd_value
  • gas_fee
  • memo/reference

Core event types

  • transfer_in
  • transfer_out
  • swap
  • lp_mint
  • lp_burn
  • stake
  • unstake
  • reward_accrual
  • reward_claim
  • fee_accrual
  • fee_distribution
  • wrap
  • unwrap
  • bridge

This normalized layer is the foundation for reconciliation.


4) Separate balances into three layers

You should reconcile:

A. Wallet balances

The actual token balances held by the wallet.

B. Protocol balances

Balances held in:

  • LP pools
  • staking contracts
  • lending positions
  • vaults

C. Accounting balances

What your books say you own/are owed.

This separation is important because:

  • wallet balance may not reflect staked assets
  • LP position value is not just token balance
  • rewards may be accrued but not yet claimed

5) Handle LP positions correctly

LP positions are often the trickiest part.

For constant-product LPs

When a wallet deposits two tokens into a pool:

  • record a transfer out of the two tokens
  • record an LP position acquisition
  • the LP token becomes the asset held

When burning LP:

  • record LP disposal
  • record receipt of underlying tokens

For concentrated liquidity (e.g., Uniswap V3)

Track:

  • tokenId
  • deposited token amounts
  • liquidity
  • fees accrued
  • fees collected
  • withdrawals

You need to reconstruct position state from contract events:

  • Mint
  • IncreaseLiquidity
  • DecreaseLiquidity
  • Collect
  • Burn

Accounting treatment

Usually:

  • LP shares are an asset
  • underlying exposure changes with market prices
  • fees earned are income when accrued or collected, depending on policy

6) Handle staking and reward flows

Common staking lifecycle

  1. Deposit token into staking contract
  2. Token is locked or represented by receipt token
  3. Rewards accrue over time
  4. Rewards are claimed or auto-compounded
  5. Principal is withdrawn later

Accounting rules to encode

  • Stake deposit: reclassify asset from wallet to staked asset
  • Reward accrual: recognize income as earned if using accrual basis
  • Reward claim: increase wallet balance; do not double-count income if already accrued
  • Auto-compound: treat reward as income + reinvestment

Edge case

If rewards are paid in a different token than the staked token, you need:

  • FMV at time of receipt
  • potential gain/loss on subsequent disposal

7) Add wallet reconciliation logic

To reconcile wallet balances:

Step-by-step

  1. Pull current balances from chain
  2. Aggregate all indexed transfers and protocol interactions
  3. Compute expected balances by asset
  4. Compare expected vs actual chain balances
  5. Investigate:
    • missing transactions
    • failed txs
    • token rebases
    • airdrops
    • dust
    • internal protocol transfers

Important edge cases

  • Rebasing tokens: balance changes without transfers
  • Fee-on-transfer tokens: sent amount differs from received amount
  • Wrapped assets: need unwrap/wrap conversion
  • Bridges: asset leaves one chain and arrives on another
  • Airdrops: may appear without user action

8) Build a position engine

For LPs and staking, you need a state engine that updates holdings over time.

Inputs

  • event stream
  • contract state snapshots
  • token prices
  • exchange rates

Outputs

  • current holdings
  • cost basis
  • unrealized gains/losses
  • accrued rewards
  • realized P/L on exits

This can be implemented as:

  • event-sourced ledger
  • periodic snapshots + deltas
  • hybrid model

A hybrid model is often best:

  • use events for accuracy
  • use snapshots to validate reconciliation

9) Accounting entries you’ll need

At minimum, support these journal entries:

Wallet deposit

  • Dr Crypto Asset
  • Cr Deposit/Equity/Income Source

LP mint

  • Dr LP Token / Position Asset
  • Cr Underlying Assets

LP burn

  • Dr Underlying Assets
  • Cr LP Token / Position Asset

Reward accrual

  • Dr Reward Receivable
  • Cr Reward Income

Reward claim

  • Dr Wallet Token
  • Cr Reward Receivable

Fees collected

  • Dr Wallet Token
  • Cr Fee Income or Reward Income

Gas fees

  • Dr Gas Expense
  • Cr Native Token / Cash

Use a consistent chart of accounts:

  • Assets
  • Liabilities
  • Income
  • Expenses
  • Equity
  • Receivables

10) Choose your software stack

If building in-house

Common stack:

  • Indexer: Python, TypeScript, or Rust
  • Database: PostgreSQL
  • ETL/orchestration: Airflow, Dagster, Prefect
  • Blockchain access: web3.py / ethers.js / viem
  • Accounting layer: custom ledger service
  • Dashboarding: Metabase, Superset, Power BI

If buying software

Look for support for:

  • wallet address ingestion
  • DeFi protocol parsing
  • LP and staking support
  • multi-chain reconciliation
  • tax lots and FMV
  • export to ERP/accounting tools

Be careful: many tools handle transfers well but struggle with:

  • Uniswap V3
  • auto-compounding vaults
  • multi-step staking
  • rebasing assets

11) Reconciliation workflow

A good workflow is:

  1. Ingest raw chain data daily or near-real-time
  2. Normalize events
  3. Classify protocol interactions
  4. Value transactions
  5. Update ledger
  6. Reconcile balances
  7. Flag exceptions
  8. Review manual adjustments
  9. Lock reporting period

Exception categories

  • missing pricing data
  • unknown contract
  • failed transaction
  • partial fill
  • unrecognized token
  • contract upgrade / proxy change
  • mismatched LP state

12) Auditability and controls

For finance-grade accounting, make sure every number is traceable.

Keep:

  • tx hash
  • log index
  • block number
  • contract address
  • ABI/event signature
  • price source
  • valuation timestamp
  • manual adjustment log

Controls to add:

  • immutable raw event store
  • versioned classification rules
  • approvals for manual edits
  • period close snapshots
  • reconciliation reports

13) Practical implementation order

If you’re starting from scratch, do it in this order:

  1. Wallet balance tracking
  2. ERC-20 transfers
  3. LP deposits and withdrawals
  4. Simple staking rewards
  5. Price valuation
  6. Fee/reward accrual
  7. Uniswap V3 / advanced LPs
  8. Cross-chain bridges
  9. Auto-compounding vaults
  10. ERP export and reporting

Start simple; DeFi complexity compounds quickly.


14) Recommended minimum viable setup

If you want a lean first version:

  • One chain
  • One wallet group
  • ERC-20 + native assets
  • One or two major LP protocols
  • One staking protocol
  • Daily sync
  • USD valuation
  • Journal export to CSV/QuickBooks/Xero

That gets you a working reconciliation pipeline without overengineering.


15) Questions to answer before implementation

  • Which chains are in scope?
  • Which protocols do you use?
  • Do you need tax reporting or just accounting?
  • Cash basis or accrual basis?
  • Do you need real-time or month-end?
  • How many wallets?
  • Do you need consolidated entity reporting?
  • Do you need audit-ready controls?

If you want, I can also help you with either:

  1. a reference architecture diagram,
  2. a database schema for on-chain accounting, or
  3. a step-by-step implementation plan in Python/SQL.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.