Skip to content

Reading Market State ​

Read-only calls do not require a connected wallet. Use them to discover pools, inspect balances and rates, fetch oracle prices, and load user positions. All methods return values already unwrapped from Soroban's Result type and scaled where noted.

Market service ​

Accessed via client.market.


getMarketData ​

Fetch the full market snapshot in one call — all pools, computed APYs, global state, and oracle decimals.

typescript
const marketData = await client.market.getMarketData()

Returns a MarketData object. This is the most efficient way to render a market overview, since it avoids per-pool round trips.


getAllPools ​

List every pool registered on the market.

typescript
const pools = await client.market.getAllPools()

Returns an array of Pool entries.


getPoolData ​

Fetch a single pool with computed values (APYs, oracle price) for the given pool address.

typescript
const poolData = await client.market.getPoolData(poolAddress)
ParameterTypeDescription
poolAddressstringTarget pool address

Returns a Pool.


getPoolInfo ​

Fetch the raw stored pool record (balances, rates, configuration) without simulation-derived fields.

typescript
const pool = await client.market.getPoolInfo(poolAddress)

Returns a Pool.


getPoolAssetOraclePrice ​

Fetch the current oracle price for a pool's asset, already scaled to a human-readable number using the market's oracle decimals.

typescript
const price = await client.market.getPoolAssetOraclePrice(poolAddress)
ParameterTypeDescription
poolAddressstringTarget pool address

Returns a number (returns 0 if the oracle has no price).


simulateWithdraw ​

Preview a withdrawal — the resulting amount and fees — without submitting a transaction. Use this to show users the actual amount they will receive before they commit.

typescript
const result = await client.market.simulateWithdraw(user, poolAddress, '500', assetDecimals)
ParameterTypeDescription
userObligationKeyObligation to withdraw from
poolAddressstringTarget pool address
amountstring | numberHuman-readable amount to preview
assetDecimalsnumberDecimal precision of the pool's token

Returns a WithdrawResult.

Obligation service ​

Accessed via client.obligation.


getUserObligation ​

Load a user's obligation — their deposits, borrows, and collateral positions.

typescript
import type { ObligationKey } from '@alula/market-sdk'

const user: ObligationKey = { user: 'GABC...', seed: undefined }
const obligation = await client.obligation.getUserObligation(user)
ParameterTypeDescription
userObligationKeyObligation to load

Returns an Obligation. The seed inside the key selects which position type to read — see Concepts for how standard, earn, and multiply obligations differ.