SpieldSpield
Developers

Reading state

Read Spield positions, prices, solvency and series status. Use the SDK's getInfo and getPosition, or simulate contract reads directly. Free, no signing.

Everything Spield exposes for reading is a free simulation. You need no wallet and pay no fees. Use @spield/sdk if you can, and simulate contract calls yourself if you need something it does not return.

With the SDK

import { SpieldClient, mainnet } from '@spield/sdk';

const spield = new SpieldClient({ network: mainnet() });       // read-only: no signer needed
await spield.loadSeries();
const series = spield.series('mainnet-blend-3');

const info = await series.getInfo();
info.impliedApyPct;      // fixed APY a PT buyer locks in now (null if no liquidity or matured)
info.ptPrice;            // price of 1 PT in the series asset
info.liquidity.formatted;
info.tvl.formatted;
info.depositCap;         // TokenAmount, or null when uncapped
info.depositHeadroom;    // room left under the cap
info.fixedRateVaultPct;  // the vault's rate for a new receipt (Blend series only)
info.paused;
info.actions;            // what works right now: buyPt, sellPt, buyYt, sellYt, redeem, claimYield, fixedRateDeposit
info.warnings;           // plain-English reasons when something is unavailable

const pos = await series.getPosition({ owner: 'G...' });
pos.assetBalance.formatted;    // USDC (or USTRY) in the wallet
pos.pt.formatted;
pos.yt.formatted;
pos.claimableYield.formatted;  // what claimYield() would collect
pos.redeemable.formatted;      // what redeem() would pay now
pos.estimatedValue.formatted;  // PT, YT, claimable yield, LP and open receipts
pos.fixedRateReceipts;         // Blend series: open vault receipts

Across every series at once:

const portfolio = await spield.getPortfolio({ owner: 'G...' });  // every non-empty position, live and matured
const { series: all, errors } = await spield.getAllInfo({ status: 'live' });

Drive your UI from info.actions and info.warnings, and gate buttons on the position (pos.redeemable.raw > 0n, pos.claimableYield.raw > 0n).

What to read, and where

The raw reads behind those fields:

You wantRead
Maturityexpiry() on the Yield contract (unix seconds)
Is the series maturedCompare expiry() with the current ledger time, or is_expired() on Yield
USDC per SRexchange_rate() on SR (12-decimal)
Is the pool worth less than the stored raterate_snapshot() or realizable_rate() on SR
PT price, implied APYpt_price(), implied_apy() on the SR Market (12-decimal)
Pool reservesreserves() on the SR Market, (pt, sr)
A quotequote_buy_pt(sr_in), quote_sell_pt(pt_in), quote_buy_yt(yt_out), quote_sell_yt(yt_in) on the market, or the Router's quote_* for USDC
Fee for a tradefee_preview(notional) on the market
An LP's positionlp_position(lp) on the market, (shares, pt, sr)
Claimable YT yieldclaimable_interest(user) on Yield (SR, before the fee), or quote_claim_yield(user) on the Router (USDC, after the fee)
PT balanceThe PT SAC's balance(id), or the classic asset balance on Horizon
YT balancebalance(id) on the Yield contract
Deposit cap and roomdeposit_cap(), deposit_headroom() on SR
Vault rate for a depositquote(amount) on the Vault, (payout, coupon, rate_bps)
A vault receiptget_receipt(receipt_id), redeem_remaining(receipt_id)
Vault healthstats() on the Vault
What the pool can pay out nowmax_redeemable() on SR

Solvency

Solvency is a read, not a promise:

// Yield: (sr_held, sr_required, surplus)
const [held, required, surplus] = await read(YIELD_ID, 'solvency');

sr_held is the SR the engine holds. sr_required is what it owes PT and YT holders. Surplus is owed to YT holders, not to the protocol. In the SDK, SrProtocolClient.getHealth() (from @spield/sdk/advanced) returns solvency for a whole series in one call. See Solvency for what the numbers mean.

Reading contracts directly

A read is a Soroban simulateTransaction. The source account only has to be a valid address. It does not need to exist or hold funds.

import { Account, Address, BASE_FEE, Contract, TransactionBuilder, nativeToScVal, rpc, scValToNative, xdr } from '@stellar/stellar-sdk';

const RPC_URL = 'https://mainnet.sorobanrpc.com';              // or https://soroban-testnet.stellar.org
const PASSPHRASE = 'Public Global Stellar Network ; September 2015'; // or 'Test SDF Network ; September 2015'
const SOURCE = 'G...';                                          // any valid account address
const server = new rpc.Server(RPC_URL);

async function read<T = unknown>(contractId: string, method: string, args: xdr.ScVal[] = []): Promise<T> {
  const tx = new TransactionBuilder(new Account(SOURCE, '0'), { fee: BASE_FEE, networkPassphrase: PASSPHRASE })
    .addOperation(new Contract(contractId).call(method, ...args))
    .setTimeout(30)
    .build();
  const sim = await server.simulateTransaction(tx);
  if (rpc.Api.isSimulationError(sim)) throw new Error(sim.error);
  if (!sim.result) throw new Error(`${method} returned nothing`);
  return scValToNative(sim.result.retval) as T;
}

// Mainnet Blend Series 3 (addresses on the Contract addresses page)
const YIELD = 'CD3KTKCMQ6OZ6H7T66TDUGCFJZJQMPQFB7ESZGX6ULJONXDFOGUXF2ZR';
const SR = 'CDAYFUITKOEVBHBRFOVEVFARYBNW3DRUS2WVKUD25ATQ4MZKNBFMEUTD';
const MARKET = 'CCPZ64XUKZ43PE2ZYKZTNU6C22NTOYAXEG5C2X277LOXNUAX4MNJO4HM';

const expiry = await read<bigint>(YIELD, 'expiry');                        // unix seconds
const rate = await read<bigint>(SR, 'exchange_rate');                      // 12-decimal
const ptPrice = await read<bigint>(MARKET, 'pt_price');                    // 12-decimal, 0n = no price
const [ptReserve, srReserve] = await read<[bigint, bigint]>(MARKET, 'reserves');
const claimable = await read<bigint>(YIELD, 'claimable_interest',
  [new Address('G...').toScVal()]);                                         // SR, 7 decimals

Types

i128 values come back as bigint. Pass i128 arguments with nativeToScVal(n, { type: 'i128' }) and addresses with new Address(a).toScVal(). A quote_* read that returns 0n means there is no quote (empty pool or expired series). It is not an error.

Series status in one view

A series is live before expiry() and matured after it. After maturity:

  • mint_py, swaps and add_liquidity are refused.
  • redeem_py burns PT alone, 1:1.
  • Vault receipts are redeemable, YT yield is claimable and remove_liquidity works.
  • pt_price() and implied_apy() stop being meaningful.

is_paused() on each contract tells you whether new exposure is paused. Exits are never paused.

status() on the USTRY Series is the single health read:

const status = await read(USTRY_SERIES, 'status');
// { state, oracle_ok, fresh, entry_open, boundary_seen, finalizable, synced }
  • entry_open is whether new deposits, splits and YT buys can happen now (fresh NAV, not paused, before expiry).
  • fresh is whether the newest NAV sample is within max_age.
  • finalizable is whether finalize() can run. After maturity PT redemption needs it.
  • synced is false when published NAV has not been folded in yet. A sync() before claim_yield pays that yield.

entry_open does not include the split cap: compare split_cap() with state.backing yourself, or let the SDK's getInfo() do it.

Verifying what is running

Every contract exposes its build and governance state:

ReadMeaning
code_hash()The SHA-256 of the live WASM. Compare it with a build you reproduced.
version()A human-readable version string (informational).
admin()The current admin. On mainnet this is the 2-of-3 multisig.
is_paused()Whether new exposure is paused.
pending_upgrade(), timelock()A scheduled upgrade (its hash is public for the whole delay) and the delay in seconds.
pending_admin()A proposed admin change, if any.

Next: Integrating for writes, and Events for history.

On this page