Skip to content

Commit 1c20aa5

Browse files
committed
spotFiller: fix undefined fallback prices
1 parent 730dbd0 commit 1c20aa5

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/bots/spotFiller.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ type FallbackLiquiditySource = 'serum' | 'phoenix';
140140

141141
type NodesToFillWithContext = {
142142
nodesToFill: NodeToFill[];
143-
fallbackAskSource: FallbackLiquiditySource;
144-
fallbackBidSource: FallbackLiquiditySource;
143+
fallbackAskSource?: FallbackLiquiditySource;
144+
fallbackBidSource?: FallbackLiquiditySource;
145145
};
146146

147147
export class SpotFillerBot implements Bot {
148148
public readonly name: string;
149149
public readonly dryRun: boolean;
150-
public readonly defaultIntervalMs: number = 5000;
150+
public readonly defaultIntervalMs: number = 2000;
151151

152152
private slotSubscriber: SlotSubscriber;
153153
private bulkAccountLoader?: BulkAccountLoader;
@@ -596,11 +596,7 @@ export class SpotFillerBot implements Bot {
596596
market: SpotMarketAccount,
597597
dlob: DLOB
598598
): {
599-
nodesToFill: {
600-
nodesToFill: Array<NodeToFill>;
601-
fallbackAskSource: FallbackLiquiditySource;
602-
fallbackBidSource: FallbackLiquiditySource;
603-
};
599+
nodesToFill: NodesToFillWithContext;
604600
nodesToTrigger: Array<NodeToTrigger>;
605601
} {
606602
const oraclePriceData = this.driftClient.getOracleDataForSpotMarket(
@@ -659,7 +655,7 @@ export class SpotFillerBot implements Bot {
659655
serumPrice: BN | undefined,
660656
phoenixPrice: BN | undefined,
661657
side: 'bid' | 'ask'
662-
): [BN, FallbackLiquiditySource] {
658+
): [BN | undefined, FallbackLiquiditySource | undefined] {
663659
if (serumPrice && phoenixPrice) {
664660
if (side === 'bid') {
665661
return serumPrice.gt(phoenixPrice)
@@ -680,9 +676,7 @@ export class SpotFillerBot implements Bot {
680676
return [phoenixPrice, 'phoenix'];
681677
}
682678

683-
throw new Error(
684-
`Failed to find fallback price, serumPrice: ${serumPrice}, phoenixPrice: ${phoenixPrice}, side: ${side}`
685-
);
679+
return [undefined, undefined];
686680
}
687681

688682
private async getNodeFillInfo(nodeToFill: NodeToFill): Promise<{
@@ -1030,8 +1024,8 @@ export class SpotFillerBot implements Bot {
10301024

10311025
private async tryFillSpotNode(
10321026
nodeToFill: NodeToFill,
1033-
fallbackAskSource: FallbackLiquiditySource,
1034-
fallbackBidSource: FallbackLiquiditySource
1027+
fallbackAskSource?: FallbackLiquiditySource,
1028+
fallbackBidSource?: FallbackLiquiditySource
10351029
) {
10361030
const nodeSignature = getNodeToFillSignature(nodeToFill);
10371031
if (this.nodeIsThrottled(nodeSignature)) {

0 commit comments

Comments
 (0)