markets
Interfaces
Section titled “Interfaces”FactionMarketOfferSnapshot
Section titled “FactionMarketOfferSnapshot”Defined in: packages/sage/src/markets/index.ts:243
One cargo offer in a Faction Market.
Example
Section titled “Example”declare const offer: FactionMarketOfferSnapshot;console.log(offer.name, offer.priceAtlas);Extends
Section titled “Extends”Properties
Section titled “Properties”canBuyFromFaction
Section titled “canBuyFromFaction”readonly canBuyFromFaction: boolean;Defined in: packages/sage/src/markets/index.ts:244
canSellToFaction
Section titled “canSellToFaction”readonly canSellToFaction: boolean;Defined in: packages/sage/src/markets/index.ts:245
categoryId
Section titled “categoryId”readonly categoryId: number;Defined in: packages/sage/src/registry/index.ts:119
Inherited from
Section titled “Inherited from”CargoDefinitionSummary.categoryId
readonly id: number;Defined in: packages/sage/src/registry/index.ts:120
Inherited from
Section titled “Inherited from”readonly mint: Address;Defined in: packages/sage/src/registry/index.ts:121
Inherited from
Section titled “Inherited from”readonly name: string;Defined in: packages/sage/src/registry/index.ts:122
Inherited from
Section titled “Inherited from”priceAtlas
Section titled “priceAtlas”readonly priceAtlas: number;Defined in: packages/sage/src/markets/index.ts:247
priceRaw
Section titled “priceRaw”readonly priceRaw: bigint;Defined in: packages/sage/src/markets/index.ts:246
remainingQuantityRaw
Section titled “remainingQuantityRaw”readonly remainingQuantityRaw: bigint;Defined in: packages/sage/src/markets/index.ts:248
storageCost
Section titled “storageCost”readonly storageCost: number;Defined in: packages/sage/src/registry/index.ts:127
Encoded storage cost with 8 fractional bits: 256 means one whole storage unit.
For a nonnegative bigint quantity, use (quantity * BigInt(storageCost) + 255n) / 256n.
Round each transfer row up before summing; Fleet capacities and pod usage are whole units.
Inherited from
Section titled “Inherited from”CargoDefinitionSummary.storageCost
FactionMarketSnapshot
Section titled “FactionMarketSnapshot”Defined in: packages/sage/src/markets/index.ts:258
Immutable Faction Market configuration, lifecycle, and offers snapshot.
Example
Section titled “Example”declare const market: FactionMarketSnapshot;console.log(market.status, market.offers);Extends
Section titled “Extends”Omit<FactionMarketAccountData,"game"|"offers"|"system">
Extended by
Section titled “Extended by”Properties
Section titled “Properties”address
Section titled “address”readonly address: Address;Defined in: packages/sage/src/markets/index.ts:263
atlasBurnBasisPoints
Section titled “atlasBurnBasisPoints”readonly atlasBurnBasisPoints: number;Defined in: packages/sage/src/internal/c4/market.ts:123
Inherited from
Section titled “Inherited from”Omit.atlasBurnBasisPointsauthoredTargetQuantityRaw
Section titled “authoredTargetQuantityRaw”readonly authoredTargetQuantityRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:120
Inherited from
Section titled “Inherited from”Omit.authoredTargetQuantityRawreadonly bump: number;Defined in: packages/sage/src/internal/c4/market.ts:111
Inherited from
Section titled “Inherited from”Omit.bumpfactionId
Section titled “factionId”readonly factionId: number;Defined in: packages/sage/src/internal/c4/market.ts:113
Inherited from
Section titled “Inherited from”Omit.factionIdfaucetEnabled
Section titled “faucetEnabled”readonly faucetEnabled: boolean;Defined in: packages/sage/src/internal/c4/market.ts:125
Inherited from
Section titled “Inherited from”Omit.faucetEnabledreadonly game: EntityRef<"game">;Defined in: packages/sage/src/markets/index.ts:264
readonly kind: "factionMarket";Defined in: packages/sage/src/markets/index.ts:262
lastRestockedAtUnixSeconds
Section titled “lastRestockedAtUnixSeconds”readonly lastRestockedAtUnixSeconds: bigint;Defined in: packages/sage/src/internal/c4/market.ts:122
Inherited from
Section titled “Inherited from”Omit.lastRestockedAtUnixSecondsminimumStandingToBuy
Section titled “minimumStandingToBuy”readonly minimumStandingToBuy: number;Defined in: packages/sage/src/internal/c4/market.ts:117
Inherited from
Section titled “Inherited from”Omit.minimumStandingToBuyminimumStandingToSell
Section titled “minimumStandingToSell”readonly minimumStandingToSell: number;Defined in: packages/sage/src/internal/c4/market.ts:118
Inherited from
Section titled “Inherited from”Omit.minimumStandingToSelloffers
Section titled “offers”readonly offers: readonly FactionMarketOfferSnapshot[];Defined in: packages/sage/src/markets/index.ts:266
priceTierBasisPoints
Section titled “priceTierBasisPoints”readonly priceTierBasisPoints: readonly number[];Defined in: packages/sage/src/internal/c4/market.ts:119
Inherited from
Section titled “Inherited from”Omit.priceTierBasisPointsrestockPeriodSeconds
Section titled “restockPeriodSeconds”readonly restockPeriodSeconds: number;Defined in: packages/sage/src/internal/c4/market.ts:121
Inherited from
Section titled “Inherited from”Omit.restockPeriodSecondsstandingBasisPoints
Section titled “standingBasisPoints”readonly standingBasisPoints: number;Defined in: packages/sage/src/internal/c4/market.ts:124
Inherited from
Section titled “Inherited from”Omit.standingBasisPointsstarbaseSequenceId
Section titled “starbaseSequenceId”readonly starbaseSequenceId: bigint;Defined in: packages/sage/src/internal/c4/market.ts:115
Inherited from
Section titled “Inherited from”Omit.starbaseSequenceIdstatus
Section titled “status”readonly status: "active" | "draft" | "removed";Defined in: packages/sage/src/internal/c4/market.ts:116
Inherited from
Section titled “Inherited from”Omit.statussystem
Section titled “system”readonly system: EntityRef<"starSystem">;Defined in: packages/sage/src/markets/index.ts:265
version
Section titled “version”readonly version: number;Defined in: packages/sage/src/internal/c4/market.ts:110
Inherited from
Section titled “Inherited from”Omit.versionMethods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): unknown;Defined in: packages/sage/src/markets/index.ts:267
Returns
Section titled “Returns”unknown
LocalMarketMakerAssets
Section titled “LocalMarketMakerAssets”Defined in: packages/sage/src/markets/index.ts:115
Observed locked principal and released proceeds for one Local Market maker row.
These values classify the row’s stored amounts. Released amounts do not establish withdrawal availability or predict a future transfer.
Example
Section titled “Example”declare const assets: LocalMarketMakerAssets;console.log(assets.lockedAtlasRaw, assets.releasedCargoRaw);Properties
Section titled “Properties”lockedAtlasRaw
Section titled “lockedAtlasRaw”readonly lockedAtlasRaw: bigint;Defined in: packages/sage/src/markets/index.ts:116
lockedCargoRaw
Section titled “lockedCargoRaw”readonly lockedCargoRaw: bigint;Defined in: packages/sage/src/markets/index.ts:117
releasedAtlasRaw
Section titled “releasedAtlasRaw”readonly releasedAtlasRaw: bigint;Defined in: packages/sage/src/markets/index.ts:118
releasedCargoRaw
Section titled “releasedCargoRaw”readonly releasedCargoRaw: bigint;Defined in: packages/sage/src/markets/index.ts:119
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): unknown;Defined in: packages/sage/src/markets/index.ts:120
Returns
Section titled “Returns”unknown
LocalMarketMakerStateSnapshot
Section titled “LocalMarketMakerStateSnapshot”Defined in: packages/sage/src/markets/index.ts:100
One Profile’s maker state on one order-book side.
escrowedOrReleasedAtlas is escrowed ATLAS for bids and ATLAS released from
completed sales for asks. It does not establish that either amount is
currently withdrawable.
Example
Section titled “Example”declare const makerState: LocalMarketMakerStateSnapshot;console.log(makerState.escrowedOrReleasedAtlas);Extends
Section titled “Extends”LocalMarketMakerData
Properties
Section titled “Properties”cargoRaw
Section titled “cargoRaw”readonly cargoRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:78
Inherited from
Section titled “Inherited from”LocalMarketMakerData.cargoRawescrowedOrReleasedAtlas
Section titled “escrowedOrReleasedAtlas”readonly escrowedOrReleasedAtlas: number;Defined in: packages/sage/src/internal/c4/market.ts:77
Inherited from
Section titled “Inherited from”LocalMarketMakerData.escrowedOrReleasedAtlasescrowedOrReleasedAtlasRaw
Section titled “escrowedOrReleasedAtlasRaw”readonly escrowedOrReleasedAtlasRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:76
Inherited from
Section titled “Inherited from”LocalMarketMakerData.escrowedOrReleasedAtlasRawopenOrderCount
Section titled “openOrderCount”readonly openOrderCount: number;Defined in: packages/sage/src/internal/c4/market.ts:74
Inherited from
Section titled “Inherited from”LocalMarketMakerData.openOrderCountprofile
Section titled “profile”readonly profile: Address;Defined in: packages/sage/src/internal/c4/market.ts:73
Inherited from
Section titled “Inherited from”LocalMarketMakerData.profileprofileRef
Section titled “profileRef”readonly profileRef: EntityRef<"profile">;Defined in: packages/sage/src/markets/index.ts:101
rentBytesOwnedRaw
Section titled “rentBytesOwnedRaw”readonly rentBytesOwnedRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:75
Inherited from
Section titled “Inherited from”LocalMarketMakerData.rentBytesOwnedRawLocalMarketOrderBookSnapshot
Section titled “LocalMarketOrderBookSnapshot”Defined in: packages/sage/src/markets/index.ts:209
One translated side of a Local Market order book.
Example
Section titled “Example”declare const book: LocalMarketOrderBookSnapshot;console.log(book.orders.length);Properties
Section titled “Properties”makers
Section titled “makers”readonly makers: readonly LocalMarketMakerStateSnapshot[];Defined in: packages/sage/src/markets/index.ts:211
nextOrderIdRaw
Section titled “nextOrderIdRaw”readonly nextOrderIdRaw: bigint;Defined in: packages/sage/src/markets/index.ts:210
orders
Section titled “orders”readonly orders: readonly LocalMarketOrderSnapshot[];Defined in: packages/sage/src/markets/index.ts:212
LocalMarketOrderSnapshot
Section titled “LocalMarketOrderSnapshot”Defined in: packages/sage/src/markets/index.ts:84
One translated Local Market order.
Example
Section titled “Example”declare const order: LocalMarketOrderSnapshot;console.log(order.side, order.priceAtlas);Extends
Section titled “Extends”LocalMarketOrderData
Properties
Section titled “Properties”readonly maker: Address;Defined in: packages/sage/src/internal/c4/market.ts:65
Inherited from
Section titled “Inherited from”LocalMarketOrderData.makermakerRef
Section titled “makerRef”readonly makerRef: EntityRef<"profile">;Defined in: packages/sage/src/markets/index.ts:85
orderId
Section titled “orderId”readonly orderId: bigint;Defined in: packages/sage/src/internal/c4/market.ts:64
Inherited from
Section titled “Inherited from”LocalMarketOrderData.orderIdpriceAtlas
Section titled “priceAtlas”readonly priceAtlas: number;Defined in: packages/sage/src/internal/c4/market.ts:67
Inherited from
Section titled “Inherited from”LocalMarketOrderData.priceAtlaspriceRaw
Section titled “priceRaw”readonly priceRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:66
Inherited from
Section titled “Inherited from”LocalMarketOrderData.priceRawquantityRaw
Section titled “quantityRaw”readonly quantityRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:68
Inherited from
Section titled “Inherited from”LocalMarketOrderData.quantityRawreadonly side: "bid" | "ask";Defined in: packages/sage/src/internal/c4/market.ts:69
Inherited from
Section titled “Inherited from”LocalMarketOrderData.sideLocalMarketSnapshot
Section titled “LocalMarketSnapshot”Defined in: packages/sage/src/markets/index.ts:222
Immutable Local Market, order book, escrow, and maker-state snapshot.
Example
Section titled “Example”declare const market: LocalMarketSnapshot;console.log(market.cargo.name, market.asks.orders);Extends
Section titled “Extends”Omit<LocalMarketAccountData,"asks"|"bids"|"cargo"|"initializerProfile"|"system">
Extended by
Section titled “Extended by”Properties
Section titled “Properties”address
Section titled “address”readonly address: Address;Defined in: packages/sage/src/markets/index.ts:227
readonly asks: LocalMarketOrderBookSnapshot;Defined in: packages/sage/src/markets/index.ts:232
readonly bids: LocalMarketOrderBookSnapshot;Defined in: packages/sage/src/markets/index.ts:231
readonly bump: number;Defined in: packages/sage/src/internal/c4/market.ts:91
Inherited from
Section titled “Inherited from”Omit.bumpreadonly cargo: CargoDefinitionSummary & { amountRaw: bigint;};Defined in: packages/sage/src/markets/index.ts:230
Type Declaration
Section titled “Type Declaration”amountRaw
Section titled “amountRaw”readonly amountRaw: bigint;initializerProfile
Section titled “initializerProfile”readonly initializerProfile: EntityRef<"profile">;Defined in: packages/sage/src/markets/index.ts:229
readonly kind: "localMarket";Defined in: packages/sage/src/markets/index.ts:226
starbaseSequenceId
Section titled “starbaseSequenceId”readonly starbaseSequenceId: bigint;Defined in: packages/sage/src/internal/c4/market.ts:90
Inherited from
Section titled “Inherited from”Omit.starbaseSequenceIdsystem
Section titled “system”readonly system: EntityRef<"starSystem">;Defined in: packages/sage/src/markets/index.ts:228
vaultAtlas
Section titled “vaultAtlas”readonly vaultAtlas: number;Defined in: packages/sage/src/internal/c4/market.ts:95
Inherited from
Section titled “Inherited from”Omit.vaultAtlasvaultRaw
Section titled “vaultRaw”readonly vaultRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:94
Inherited from
Section titled “Inherited from”Omit.vaultRawversion
Section titled “version”readonly version: number;Defined in: packages/sage/src/internal/c4/market.ts:88
Inherited from
Section titled “Inherited from”Omit.versionMethods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): unknown;Defined in: packages/sage/src/markets/index.ts:233
Returns
Section titled “Returns”unknown
MarketDiscoveryOptions
Section titled “MarketDiscoveryOptions”Defined in: packages/sage/src/markets/index.ts:73
Discovery controls for Local Market finders.
Example
Section titled “Example”const options: MarketDiscoveryOptions = { commitment: 'confirmed' };Extends
Section titled “Extends”Properties
Section titled “Properties”commitment?
Section titled “commitment?”readonly optional commitment?: Commitment;Defined in: packages/sage/src/client/contracts.ts:194
Inherited from
Section titled “Inherited from”maxAgeMs?
Section titled “maxAgeMs?”readonly optional maxAgeMs?: number;Defined in: packages/sage/src/client/contracts.ts:496
Maximum age of a completed cache entry in milliseconds.
Overrides the context’s defaultMaxAgeMs. Use 0 to always revalidate or
Infinity to reuse completed cache entries until explicit invalidation.
Inherited from
Section titled “Inherited from”policy?
Section titled “policy?”readonly optional policy?: "cache-first" | "no-store";Defined in: packages/sage/src/client/contracts.ts:497
Inherited from
Section titled “Inherited from”refresh?
Section titled “refresh?”readonly optional refresh?: boolean;Defined in: packages/sage/src/client/contracts.ts:490
Bypasses a completed cache entry.
A refresh may share a compatible provider request that is already in flight, because that request has not yet produced cached state.
Inherited from
Section titled “Inherited from”signal?
Section titled “signal?”readonly optional signal?: AbortSignal;Defined in: packages/sage/src/markets/index.ts:74
Overrides
Section titled “Overrides”Functions
Section titled “Functions”deriveFactionMarketAddress()
Section titled “deriveFactionMarketAddress()”function deriveFactionMarketAddress( game, system,starbaseSequenceId): Promise<Address>;Defined in: packages/sage/src/markets/index.ts:59
Derives a Faction Market PDA from its verified generated seeds.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
game | Address |
system | Address |
starbaseSequenceId | bigint |
Returns
Section titled “Returns”Promise<Address>
Example
Section titled “Example”declare const game: Address;declare const system: Address;const address = await deriveFactionMarketAddress(game, system, 0n);deriveLocalMarketAddress()
Section titled “deriveLocalMarketAddress()”function deriveLocalMarketAddress( system, cargoId,starbaseSequenceId): Promise<Address>;Defined in: packages/sage/src/markets/index.ts:43
Derives a Local Market PDA from its verified generated seeds.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
system | Address |
cargoId | number |
starbaseSequenceId | bigint |
Returns
Section titled “Returns”Promise<Address>
Example
Section titled “Example”declare const system: Address;const address = await deriveLocalMarketAddress(system, 1, 0n);deriveLocalMarketMakerAssets()
Section titled “deriveLocalMarketMakerAssets()”function deriveLocalMarketMakerAssets(side, maker): LocalMarketMakerAssets;Defined in: packages/sage/src/markets/index.ts:161
Projects one observed maker row into side-aware locked principal and released proceeds.
The helper performs no network or signing work and does not infer fill state, fees, refunds, freshness, or whether released assets can be withdrawn.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
side | "bid" | "ask" |
maker | Pick<LocalMarketMakerStateSnapshot, "cargoRaw" | "escrowedOrReleasedAtlasRaw"> |
Returns
Section titled “Returns”Example
Section titled “Example”declare const maker: LocalMarketMakerStateSnapshot;const assets = deriveLocalMarketMakerAssets('bid', maker);console.log(assets.lockedAtlasRaw, assets.releasedCargoRaw);getFactionMarket()
Section titled “getFactionMarket()”function getFactionMarket( context, address,options?): Promise<FactionMarketSnapshot>;Defined in: packages/sage/src/markets/index.ts:557
Reads one required Faction Market by address.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
address | Address |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<FactionMarketSnapshot>
Example
Section titled “Example”declare const ctx: SageContext;declare const address: Address;const market = await getFactionMarket(ctx, address);getFactionMarketForSystem()
Section titled “getFactionMarketForSystem()”function getFactionMarketForSystem( context, system, starbaseSequenceId,options?): Promise<FactionMarketSnapshot>;Defined in: packages/sage/src/markets/index.ts:601
Derives and reads the configured Game’s Faction Market at one Starbase incarnation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
system | Address |
starbaseSequenceId | bigint |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<FactionMarketSnapshot>
Example
Section titled “Example”declare const ctx: SageContext;declare const system: Address;const market = await getFactionMarketForSystem(ctx, system, 0n);getLocalMarket()
Section titled “getLocalMarket()”function getLocalMarket( context, address,options?): Promise<LocalMarketSnapshot>;Defined in: packages/sage/src/markets/index.ts:418
Reads one required Local Market by address.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
address | Address |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<LocalMarketSnapshot>
Example
Section titled “Example”declare const ctx: SageContext;declare const address: Address;const market = await getLocalMarket(ctx, address);getLocalMarketForCargo()
Section titled “getLocalMarketForCargo()”function getLocalMarketForCargo( context, system, cargoId, starbaseSequenceId,options?): Promise<LocalMarketSnapshot>;Defined in: packages/sage/src/markets/index.ts:460
Derives and reads a Local Market for cargo at one Starbase incarnation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
system | Address |
cargoId | number |
starbaseSequenceId | bigint |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<LocalMarketSnapshot>
Example
Section titled “Example”declare const ctx: SageContext;declare const system: Address;const market = await getLocalMarketForCargo(ctx, system, 1, 0n);getLocalMarketOrdersByProfile()
Section titled “getLocalMarketOrdersByProfile()”function getLocalMarketOrdersByProfile( context, market, profile, options?): Promise<readonly LocalMarketOrderSnapshot & { makerState: LocalMarketMakerStateSnapshot;}[]>;Defined in: packages/sage/src/markets/index.ts:516
Returns one Profile’s open orders with that side’s maker state.
Bid-side ATLAS is escrowed for buy orders. Ask-side ATLAS was released from completed sell orders. Neither interpretation promises withdrawability.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
market | Address |
profile | Address |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<readonly LocalMarketOrderSnapshot & {
makerState: LocalMarketMakerStateSnapshot;
}[]>
Example
Section titled “Example”declare const ctx: SageContext;declare const market: Address;declare const profile: Address;const orders = await getLocalMarketOrdersByProfile(ctx, market, profile);getLocalMarketsBySystem()
Section titled “getLocalMarketsBySystem()”function getLocalMarketsBySystem( context, system,options?): Promise<readonly LocalMarketSnapshot[]>;Defined in: packages/sage/src/markets/index.ts:482
Discovers all Local Markets stored for one Star System.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
system | Address |
options? | MarketDiscoveryOptions |
Returns
Section titled “Returns”Promise<readonly LocalMarketSnapshot[]>
Example
Section titled “Example”declare const ctx: SageContext;declare const system: Address;const markets = await getLocalMarketsBySystem(ctx, system);maybeGetFactionMarket()
Section titled “maybeGetFactionMarket()”function maybeGetFactionMarket( context, address, options?): Promise< | FactionMarketSnapshot| undefined>;Defined in: packages/sage/src/markets/index.ts:577
Reads one optional Faction Market by address.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
address | Address |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<
| FactionMarketSnapshot
| undefined>
Example
Section titled “Example”declare const ctx: SageContext;declare const address: Address;const market = await maybeGetFactionMarket(ctx, address);maybeGetLocalMarket()
Section titled “maybeGetLocalMarket()”function maybeGetLocalMarket( context, address, options?): Promise< | LocalMarketSnapshot| undefined>;Defined in: packages/sage/src/markets/index.ts:437
Reads one optional Local Market by address.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | SageContext |
address | Address |
options? | ReadOptions |
Returns
Section titled “Returns”Promise<
| LocalMarketSnapshot
| undefined>
Example
Section titled “Example”declare const ctx: SageContext;declare const address: Address;const market = await maybeGetLocalMarket(ctx, address);