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

sdk: remove legacy methods from dlob #1368

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
96 changes: 3 additions & 93 deletions sdk/src/dlob/DLOB.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getOrderSignature, getVammNodeGenerator, NodeList } from './NodeList';
import { getOrderSignature, NodeList } from './NodeList';
import {
BASE_PRECISION,
BN,
Expand All @@ -21,8 +21,8 @@
mustBeTriggered,
OraclePriceData,
Order,
OrderActionRecord,

Check failure on line 24 in sdk/src/dlob/DLOB.ts

View workflow job for this annotation

GitHub Actions / yarn-lint

'OrderActionRecord' is defined but never used. Allowed unused vars must match /^_/u
OrderRecord,

Check failure on line 25 in sdk/src/dlob/DLOB.ts

View workflow job for this annotation

GitHub Actions / yarn-lint

'OrderRecord' is defined but never used. Allowed unused vars must match /^_/u
PerpMarketAccount,
PositionDirection,
PRICE_PRECISION,
Expand Down Expand Up @@ -170,86 +170,6 @@
return true;
}

public initFromOrders(dlobOrders: DLOBOrders, slot: number): boolean {
if (this.initialized) {
return false;
}

for (const { user, order } of dlobOrders) {
this.insertOrder(order, user.toString(), slot, false);
}

this.initialized = true;
return true;
}

public handleOrderRecord(record: OrderRecord, slot: number): void {
this.insertOrder(record.order, record.user.toString(), slot, false);
}

public handleOrderActionRecord(
record: OrderActionRecord,
slot: number
): void {
if (isOneOfVariant(record.action, ['place', 'expire'])) {
return;
}

if (isVariant(record.action, 'trigger')) {
if (record.taker !== null) {
const takerOrder = this.getOrder(record.takerOrderId, record.taker);
if (takerOrder) {
this.trigger(takerOrder, record.taker, slot, false);
}
}

if (record.maker !== null) {
const makerOrder = this.getOrder(record.makerOrderId, record.maker);
if (makerOrder) {
this.trigger(makerOrder, record.maker, slot, false);
}
}
} else if (isVariant(record.action, 'fill')) {
if (record.taker !== null) {
const takerOrder = this.getOrder(record.takerOrderId, record.taker);
if (takerOrder) {
this.updateOrder(
takerOrder,
record.taker,
slot,
record.takerOrderCumulativeBaseAssetAmountFilled
);
}
}

if (record.maker !== null) {
const makerOrder = this.getOrder(record.makerOrderId, record.maker);
if (makerOrder) {
this.updateOrder(
makerOrder,
record.maker,
slot,
record.makerOrderCumulativeBaseAssetAmountFilled
);
}
}
} else if (isVariant(record.action, 'cancel')) {
if (record.taker !== null) {
const takerOrder = this.getOrder(record.takerOrderId, record.taker);
if (takerOrder) {
this.delete(takerOrder, record.taker, slot);
}
}

if (record.maker !== null) {
const makerOrder = this.getOrder(record.makerOrderId, record.maker);
if (makerOrder) {
this.delete(makerOrder, record.maker, slot);
}
}
}
}

public insertOrder(
order: Order,
userAccount: string,
Expand Down Expand Up @@ -1261,7 +1181,7 @@
*/
*getAsks(
marketIndex: number,
fallbackAsk: BN | undefined,
_fallbackAsk: BN | undefined,
slot: number,
marketType: MarketType,
oraclePriceData: OraclePriceData,
Expand All @@ -1276,11 +1196,6 @@
this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData),
];

const marketTypeStr = getVariant(marketType) as MarketTypeStr;
if (marketTypeStr === 'perp' && fallbackAsk) {
generatorList.push(getVammNodeGenerator(fallbackAsk));
}

yield* this.getBestNode(
generatorList,
oraclePriceData,
Expand Down Expand Up @@ -1311,7 +1226,7 @@
*/
*getBids(
marketIndex: number,
fallbackBid: BN | undefined,
_fallbackBid: BN | undefined,
slot: number,
marketType: MarketType,
oraclePriceData: OraclePriceData,
Expand All @@ -1326,11 +1241,6 @@
this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData),
];

const marketTypeStr = getVariant(marketType) as MarketTypeStr;
if (marketTypeStr === 'perp' && fallbackBid) {
generatorList.push(getVammNodeGenerator(fallbackBid));
}

yield* this.getBestNode(
generatorList,
oraclePriceData,
Expand Down
39 changes: 0 additions & 39 deletions sdk/src/dlob/DLOBApiClient.ts

This file was deleted.

17 changes: 0 additions & 17 deletions sdk/src/dlob/NodeList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BN, isVariant, MarketTypeStr, Order } from '..';

Check failure on line 1 in sdk/src/dlob/NodeList.ts

View workflow job for this annotation

GitHub Actions / yarn-lint

'BN' is defined but never used. Allowed unused vars must match /^_/u
// import { PublicKey } from '@solana/web3.js';
import { createNode, DLOBNode, DLOBNodeMap } from './DLOBNode';

Expand Down Expand Up @@ -172,20 +172,3 @@
}
}
}

export function* getVammNodeGenerator(
price: BN | undefined
): Generator<DLOBNode> {
if (!price) {
return;
}
yield {
getPrice: () => price,
isVammNode: () => true,
order: undefined,
userAccount: undefined,
isUserProtectedMaker: false,
isBaseFilled: () => false,
haveFilled: false,
};
}
Loading
Loading