The Galactic Marketplace is a decentralized trading protocol on the Solana blockchain that provides an MMO Auction House experience as a public utility.
At a glance:
Fast and responsive data
Fully decentralized peer-to-peer trading through an MMO auction house-style experience
Easy integration with decentralized applications and protocols
As a user, here are some of the things you're able to do with the Galactic Marketplace:
Create your own buy and sell orders for any Solana token
Query, view, and cancel your existing orders
Buy from and sell into other people's orders
Technical Overview
If you're using GmClientService to fetch order data, you can expect price field of an Order to be the price in base units. Use uiPrice to retrieve a decimal-adjusted value.
What items can be traded on the Galactic Marketplace?
Any arbitrary itemMint can be transacted permissionlessly. This can be any tokenized asset including SFTs and NFTs.
What currency pairs are valid on the Galactic Marketplace?
There are a limited number of valid currencyMint options:
Token Symbol
Mainnet Address
ATLAS
ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx
USDC
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
Services and Examples
GmClientService
What is it?
The GmClientService is used to:
Construct Solana transactions to interact with the Galactic Marketplace
Creating orders
Canceling orders
Filling orders
Fetch metadata about registered currencies
Fetch lists of open orders for combinations of:
Specific mints
User PublicKeys
Specific currencies
See the TypeDocs for a full list of GmClientService methods
Fetch a list of supported currencies
Because the currency information is unlikely to change often this result will be cached for the lifecycle of GmClientService to reduce the total number of RPC calls made. If you wish to forcefully refetch this information pass true as an optional argument into getRegisteredCurrencies().
Fetch all open orders
Retrieve a list of all open orders for all currencies and items in the Galactic Marketplace.
Create an order
Create an order for itemMint - use orderSide to specify the direction of the trade.
When creating a Sell order, the orderCreator must deposit their itemMint into escrow and likewise when creating a Buy order they must deposit their quoteMint into escrow.
Fill an order
Note that orders can be partially filled. For example, if a player has an order to buy 10 Pearce X4s a seller can fill 4 out of those 10 while leaving the order open for other users to interact with.
getCreateExchangeTransaction() will work for both selling into a Buy order and buying from a Sell order.
Cancel an order
Orders can be canceled as long as they are still open, whether they have been partially filled or not. If a partially filled order is canceled, the unfilled portion of the order is returned to the order creator.
GmOrderbookService
Because the marketplace is fully decentralized, the methods on this service will return orders for all items being transacted on the Galactic Marketplace, even items which were not created by Star Atlas.
If you want to be sure an item was minted for Star Atlas use the Galaxy API to fetch this list.
What is it?
The GmOrderbookService is a read-only data caching layer which maintains a real-time list of all of the open orders on the Galactic Marketplace.
import {
GmEventHandler,
GmChangeEvent,
GmEventType,
GmOrderbookService,
} from '@staratlas/factory';
export class MyService implements GmEventHandler {
private gmOrderbookService: GmOrderbookService;
constructor(rpcUrl: string, programId: PublicKey) {
this.gmOrderbookService = new GmOrderbookService(rpcUrl, programId);
// Register this class as an event handler
this.gmOrderbookService.addOnEventHandler(this);
}
// onEvent will be fired any time a change occurs in the marketplace state
onEvent(event: GmChangeEvent): void {
switch(event.eventType) {
case GmEventType.orderAdded:
this.handleOrderAdded(event);
break;
case GmEventType.orderModified:
this.handleOrderModified(event);
break;
case GmEventType.orderRemoved:
this.handleOrderRemoved(event);
break;
default:
break;
}
}
private handleOrderAdded(event: GmChangeEvent): void {
console.log(event.order);
}
private handleOrderModified(event: GmChangeEvent): void {
console.log(event.order);
}
private handleOrderRemoved(event: GmChangeEvent): void {
console.log(event.order);
}
}
import { Connection, PublicKey } from '@solana/web3.js';
import { GmEventService, GmEventType, Order} from '@staratlas/factory';
const connection = new Connection();
const programId = new PublicKey();
const eventHandler = (
eventType: GmEventType,
order: Order,
slotContext: number,
) => {
console.log(eventType, order, slotContext);
}
const gmEventService = new GmEventService(
connection,
programId,
);
// As events are emitted from the program eventHandler will be called
gmEventService.setEventHandler(eventHandler);