Skip to content

Commit

Permalink
ts: avoid undefined in jit sniper
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Jan 25, 2024
1 parent dbb1b72 commit d78130e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ts/sdk/src/jitter/jitterShotgun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class JitterShotgun extends BaseJitter {
console.log('Order does not cross params yet, retrying');
} else if (e.message.includes('0x1779')) {
console.log('Order could not fill');
} else if (e.message.includes('0x1793')) {
} else if (e.message.includes('0x1793')) {
console.log('Oracle invalid, retrying');
} else {
await sleep(10000);
Expand Down
12 changes: 7 additions & 5 deletions ts/sdk/src/jitter/jitterSniper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export class JitterSniper extends BaseJitter {

// don't increase risk if we're past max positions
if (isVariant(order.marketType, 'perp')) {
const currPerpPos = this.driftClient
.getUser()
.getPerpPosition(order.marketIndex);
const currPerpPos =
this.driftClient.getUser().getPerpPosition(order.marketIndex) ||
this.driftClient.getUser().getEmptyPosition(order.marketIndex);
if (
currPerpPos.baseAssetAmount.lt(ZERO) &&
isVariant(order.direction, 'short')
Expand Down Expand Up @@ -204,7 +204,8 @@ export class JitterSniper extends BaseJitter {
minPosition: params.minPosition,
bid: params.bid,
ask: params.ask,
postOnly: params.postOnlyParams ?? PostOnlyParams.MUST_POST_ONLY,
postOnly:
params.postOnlyParams ?? PostOnlyParams.MUST_POST_ONLY,
priceType: params.priceType,
referrerInfo,
subAccountId: params.subAccountId,
Expand Down Expand Up @@ -315,7 +316,8 @@ export class JitterSniper extends BaseJitter {

// if it doesnt cross during auction, check if limit price crosses
if (!willCross) {
const slotAfterAuction = order.slot.toNumber() + order.auctionDuration + 1;
const slotAfterAuction =
order.slot.toNumber() + order.auctionDuration + 1;
const limitPrice = getLimitPrice(order, oraclePrice, slotAfterAuction);
if (!limitPrice) {
willCross = true;
Expand Down

0 comments on commit d78130e

Please sign in to comment.