positions method

Future<List<OpenPosition>> positions(
  1. String owner
)

All open positions for an owner, enumerated from the chain (the account's positions Table): 1 call per page warm, +2 resolution calls once per owner. Returns [] for owners with no Predict account.

Implementation

Future<List<OpenPosition>> positions(String owner) async {
  var handle = _c._positionsCache[owner];
  if (handle?.positionsTableId == null) {
    final resolved = await positions_reads.resolvePositionsTable(
        _c._client, _c._config, owner);
    if (resolved == null) return []; // never onboarded — do not cache
    if (resolved.positionsTableId != null) {
      _c._positionsCache[owner] = resolved;
    }
    handle = resolved;
  }
  final tableId = handle!.positionsTableId;
  if (tableId == null) return [];
  return positions_reads.positionsFromTable(_c._client, tableId);
}