markets
Interfaces
Section titled “Interfaces”FactionMarketOfferSnapshot
Section titled “FactionMarketOfferSnapshot”Defined in: packages/sage/src/markets/index.ts:263
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:264
canSellToFaction
Section titled “canSellToFaction”readonly canSellToFaction: boolean;Defined in: packages/sage/src/markets/index.ts:265
categoryId
Section titled “categoryId”readonly categoryId: number;Defined in: packages/sage/src/registry/index.ts:141
Inherited from
Section titled “Inherited from”CargoDefinitionSummary.categoryId
readonly id: number;Defined in: packages/sage/src/registry/index.ts:142
Inherited from
Section titled “Inherited from”readonly mint: Address;Defined in: packages/sage/src/registry/index.ts:143
Inherited from
Section titled “Inherited from”readonly name: string;Defined in: packages/sage/src/registry/index.ts:144
Inherited from
Section titled “Inherited from”priceAtlas
Section titled “priceAtlas”readonly priceAtlas: number;Defined in: packages/sage/src/markets/index.ts:267
priceRaw
Section titled “priceRaw”readonly priceRaw: bigint;Defined in: packages/sage/src/markets/index.ts:266
remainingQuantityRaw
Section titled “remainingQuantityRaw”readonly remainingQuantityRaw: bigint;Defined in: packages/sage/src/markets/index.ts:268
storageCost
Section titled “storageCost”readonly storageCost: number;Defined in: packages/sage/src/registry/index.ts:149
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:278
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:283
atlasBurnBasisPoints
Section titled “atlasBurnBasisPoints”readonly atlasBurnBasisPoints: number;Defined in: packages/sage/src/internal/c4/market.ts:126
Inherited from
Section titled “Inherited from”Omit.atlasBurnBasisPointsauthoredTargetQuantityRaw
Section titled “authoredTargetQuantityRaw”readonly authoredTargetQuantityRaw: bigint;Defined in: packages/sage/src/internal/c4/market.ts:123
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:128
Inherited from
Section titled “Inherited from”Omit.faucetEnabledreadonly game: EntityRef<"game">;Defined in: packages/sage/src/markets/index.ts:284
readonly kind: "factionMarket";Defined in: packages/sage/src/markets/index.ts:282
lastRestockedAtUnixSeconds
Section titled “lastRestockedAtUnixSeconds”readonly lastRestockedAtUnixSeconds: bigint;Defined in: packages/sage/src/internal/c4/market.ts:125
Inherited from
Section titled “Inherited from”Omit.lastRestockedAtUnixSecondsminimumStandingToBuy
Section titled “minimumStandingToBuy”readonly minimumStandingToBuy: number;Defined in: packages/sage/src/internal/c4/market.ts:119
Standing needed to buy; -1000 or less opens buying to everyone, without Faction Standing.
Inherited from
Section titled “Inherited from”Omit.minimumStandingToBuyminimumStandingToSell
Section titled “minimumStandingToSell”readonly minimumStandingToSell: number;Defined in: packages/sage/src/internal/c4/market.ts:121
Standing needed to sell; -1000 or less opens selling to everyone.
Inherited from
Section titled “Inherited from”Omit.minimumStandingToSelloffers
Section titled “offers”readonly offers: readonly FactionMarketOfferSnapshot[];Defined in: packages/sage/src/markets/index.ts:286
priceTierBasisPoints
Section titled “priceTierBasisPoints”readonly priceTierBasisPoints: readonly number[];Defined in: packages/sage/src/internal/c4/market.ts:122
Inherited from
Section titled “Inherited from”Omit.priceTierBasisPointsrestockPeriodSeconds
Section titled “restockPeriodSeconds”readonly restockPeriodSeconds: number;Defined in: packages/sage/src/internal/c4/market.ts:124
Inherited from
Section titled “Inherited from”Omit.restockPeriodSecondsstandingBasisPoints
Section titled “standingBasisPoints”readonly standingBasisPoints: number;Defined in: packages/sage/src/internal/c4/market.ts:127
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:285
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:287
Returns
Section titled “Returns”unknown
LocalMarketMakerAssets
Section titled “LocalMarketMakerAssets”Defined in: packages/sage/src/markets/index.ts:135
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:136
lockedCargoRaw
Section titled “lockedCargoRaw”readonly lockedCargoRaw: bigint;Defined in: packages/sage/src/markets/index.ts:137
releasedAtlasRaw
Section titled “releasedAtlasRaw”readonly releasedAtlasRaw: bigint;Defined in: packages/sage/src/markets/index.ts:138
releasedCargoRaw
Section titled “releasedCargoRaw”readonly releasedCargoRaw: bigint;Defined in: packages/sage/src/markets/index.ts:139
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): unknown;Defined in: packages/sage/src/markets/index.ts:140
Returns
Section titled “Returns”unknown
LocalMarketMakerStateSnapshot
Section titled “LocalMarketMakerStateSnapshot”Defined in: packages/sage/src/markets/index.ts:120
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:121
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:229
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:231
nextOrderIdRaw
Section titled “nextOrderIdRaw”readonly nextOrderIdRaw: bigint;Defined in: packages/sage/src/markets/index.ts:230
orders
Section titled “orders”readonly orders: readonly LocalMarketOrderSnapshot[];Defined in: packages/sage/src/markets/index.ts:232
LocalMarketOrderSnapshot
Section titled “LocalMarketOrderSnapshot”Defined in: packages/sage/src/markets/index.ts:104
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:105
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:242
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:247
readonly asks: LocalMarketOrderBookSnapshot;Defined in: packages/sage/src/markets/index.ts:252
readonly bids: LocalMarketOrderBookSnapshot;Defined in: packages/sage/src/markets/index.ts:251
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:250
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:249
readonly kind: "localMarket";Defined in: packages/sage/src/markets/index.ts:246
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:248
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:253
Returns
Section titled “Returns”unknown
MarketDiscoveryOptions
Section titled “MarketDiscoveryOptions”Defined in: packages/sage/src/markets/index.ts:93
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:225
Inherited from
Section titled “Inherited from”maxAgeMs?
Section titled “maxAgeMs?”readonly optional maxAgeMs?: number;Defined in: packages/sage/src/client/contracts.ts:562
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:563
Inherited from
Section titled “Inherited from”refresh?
Section titled “refresh?”readonly optional refresh?: boolean;Defined in: packages/sage/src/client/contracts.ts:556
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:94
Overrides
Section titled “Overrides”Functions
Section titled “Functions”deriveFactionMarketAddress()
Section titled “deriveFactionMarketAddress()”function deriveFactionMarketAddress( programs, game, system,starbaseSequenceId): Promise<Address>;Defined in: packages/sage/src/markets/index.ts:73
Derives a Faction Market PDA from its verified generated seeds.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
programs | SageProgramAddresses |
game | Address |
system | Address |
starbaseSequenceId | bigint |
Returns
Section titled “Returns”Promise<Address>
Example
Section titled “Example”declare const ctx: SageContext;declare const game: Address;declare const system: Address;const address = await deriveFactionMarketAddress( ctx.programs, game, system, 0n,);deriveLocalMarketAddress()
Section titled “deriveLocalMarketAddress()”function deriveLocalMarketAddress( programs, system, cargoId,starbaseSequenceId): Promise<Address>;Defined in: packages/sage/src/markets/index.ts:45
Derives a Local Market PDA from its verified generated seeds.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
programs | SageProgramAddresses |
system | Address |
cargoId | number |
starbaseSequenceId | bigint |
Returns
Section titled “Returns”Promise<Address>
Example
Section titled “Example”declare const ctx: SageContext;declare const system: Address;const address = await deriveLocalMarketAddress(ctx.programs, system, 1, 0n);deriveLocalMarketMakerAssets()
Section titled “deriveLocalMarketMakerAssets()”function deriveLocalMarketMakerAssets(side, maker): LocalMarketMakerAssets;Defined in: packages/sage/src/markets/index.ts:181
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:584
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:628
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:440
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:482
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:543
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:509
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:604
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:459
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);