Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment explaining price in fill log result #282

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/ts/src/fillFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function toFillLogResult(
taker: fillLog.taker.toBase58(),
baseAtoms: fillLog.baseAtoms.inner.toString(),
quoteAtoms: fillLog.quoteAtoms.inner.toString(),
price: convertU128(fillLog.price.inner),
priceAtoms: convertU128(fillLog.price.inner),
takerIsBuy: fillLog.takerIsBuy,
isMakerGlobal: fillLog.isMakerGlobal,
makerSequenceNumber: fillLog.makerSequenceNumber.toString(),
Expand Down
4 changes: 2 additions & 2 deletions client/ts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type FillLogResult = {
baseAtoms: string;
/** Number of quote atoms traded. */
quoteAtoms: string;
/** Price as float. Quote atoms per base atom. */
price: number;
/** Price as float. Quote atoms per base atom. Client is responsible for translating to tokens. */
priceAtoms: number;
/** Boolean to indicate which side the trade was. */
takerIsBuy: boolean;
/** Boolean to indicate whether the maker side is global. */
Expand Down
8 changes: 4 additions & 4 deletions debug-ui/scripts/stats-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class ManifestStatsServer {
private baseVolumeAtomsCheckpoints: Map<string, number[]> = new Map();
private quoteVolumeAtomsCheckpoints: Map<string, number[]> = new Map();

// Last price by market
// Last price by market. Price is in atoms per atom.
private lastPriceByMarket: Map<string, number> = new Map();

// Market objects used for mints and decimals.
Expand Down Expand Up @@ -111,7 +111,7 @@ export class ManifestStatsServer {

this.ws.onmessage = async (message) => {
const fill: FillLogResult = JSON.parse(message.data.toString());
const { market, baseAtoms, quoteAtoms, price, slot } = fill;
const { market, baseAtoms, quoteAtoms, priceAtoms, slot } = fill;

// Do not accept old spurious messages.
if (this.lastFillSlot > slot) {
Expand Down Expand Up @@ -144,13 +144,13 @@ export class ManifestStatsServer {
}
lastPrice.set(
{ market },
price *
priceAtoms *
10 **
(this.markets.get(market)!.baseDecimals() -
this.markets.get(market)!.quoteDecimals()),
);

this.lastPriceByMarket.set(market, price);
this.lastPriceByMarket.set(market, priceAtoms);
this.baseVolumeAtomsSinceLastCheckpoint.set(
market,
this.baseVolumeAtomsSinceLastCheckpoint.get(market)! +
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cks-systems/manifest-sdk",
"version": "0.1.67",
"version": "0.1.68",
"files": [
"dist/",
"README.md",
Expand Down
Loading