Start typing to search this publication.
eth news
Open menu

Subscribe to eth news

Get new posts delivered straight to your inbox.

SparkLend getUserAccountData vs UiPoolDataProvider: Which Read?

eth news
3 min read

SparkLend’s Pool.getUserAccountData is the right read for account health and borrow capacity; UiPoolDataProvider is the right read when a dashboard needs per-asset balances and collateral flags. For supplying assets, borrowing against collateral, or managing a position, SparkLend is the lending market these reads describe. The Pool returns an account aggregate, while the Aave V3 periphery helper batches reserve-level data.

How Do You Read and Convert a User Position?

Read Pool.getUserAccountData(user) for six values: totalCollateralBase, totalDebtBase, availableBorrowsBase, currentLiquidationThreshold, ltv, and healthFactor. The first three use the oracle’s base currency units; divide by the oracle’s base currency unit to display them. LTV and liquidation threshold are collateral-weighted averages in basis points. Health factor uses 18-decimal WAD precision.

Call UiPoolDataProvider.getUserReservesData(provider, user) with the PoolAddressesProvider and user address when you need asset rows. Its result includes each reserve’s scaled supply balance, scaled variable debt, collateral-enabled flag, and the user’s E-Mode category. The Aave V3 periphery source reads those scaled balances from the position tokens: they are amounts before accrued interest is applied.

For each reserve, calculate current token units as scaled balance × current index ÷ 1e27. Use the Pool’s normalized liquidity index for supply and normalized variable borrow index for debt, then divide by the asset’s token-decimal unit. These indexes use 27-decimal ray precision. Read both calls at the same block so the dashboard rows and account totals describe one position.

Take a position with 1 scaled WETH supplied and 1,000 scaled USDS borrowed. At hypothetical indexes of 1.05e27 and 1.02e27, its rows show 1.05 WETH and 1,020 USDS. Suppose the oracle values WETH at $2,000 and USDS at $1, with an 80% liquidation threshold and 75% LTV. The Pool then reports $2,100 collateral, $1,020 debt, about 1.65 health factor, and $555 borrow headroom. If only the borrow index rises to 1.03e27, debt becomes 1,030 USDS and health falls to about 1.63; the Pool remains the health read.

What Else Do These Reads Depend On?

These SparkLend reads depend on the market’s oracle values and the addresses of its deployed contracts.

How to calculate health factor from SparkLend contract data?

The health factor means liquidation-weighted collateral value divided by debt value. Divide the Pool’s healthFactor by 1e18 to display it; below 1, the position is liquidatable. The Pool applies its oracle prices, whose sources can include Chainlink.

Where to find SparkLend contract addresses on Ethereum?

Find the Ethereum PoolAddressesProvider in Spark’s official address registry, then call getPool() for the current Pool address. Verify the separate UiPoolDataProvider deployment before using its ABI. For a health monitor or liquidation bot, the core Pool call alone supplies the required signal.

Next, choose the read your integration needs and compare one account’s converted rows with its Pool totals; that gives you a checked starting point for the position display.

How Do You Put These Reads Into Practice?

Put the two reads into practice according to the output your application needs.

How do I get SparkLend supply and borrow APY from reserve data?

Read each reserve’s liquidityRate and variableBorrowRate, divide the ray values by 1e27, and apply the reserve’s interest accrual model to display annual yield. Refresh them as utilization changes.

How do I detect when a SparkLend position becomes liquidatable?

Poll Pool.getUserAccountData at current blocks and compare healthFactor with 1e18. Recheck the latest block before acting because prices, interest, and balances can change.

Can I read SparkLend positions with a subgraph instead of RPC calls?

Use a subgraph to discover accounts and inspect history. For a current health decision, confirm the account through the Pool; for current asset amounts, apply the latest normalized indexes to its scaled balances.

Subscribe to eth news