Skip to content

Commit

Permalink
fix: price to tick error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Sep 8, 2024
1 parent 9f33e44 commit 15df9a9
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions packages/web/hooks/limit-orders/use-place-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,26 @@ export const usePlaceLimit = ({
return;
}

// The requested price must account for the ratio between the quote and base asset as the base asset may not be a stablecoin.
// To account for this we divide by the quote asset price.
const tickId = priceToTick(
priceState.price.quo(quoteAssetPrice.toDec()).mul(normalizationFactor)
);
const msg = {
place_limit: {
tick_id: parseInt(tickId.toString()),
order_direction: orderDirection,
quantity,
claim_bounty: CLAIM_BOUNTY,
},
};
try {
// The requested price must account for the ratio between the quote and base asset as the base asset may not be a stablecoin.
// To account for this we divide by the quote asset price.
const tickId = priceToTick(
priceState.price.quo(quoteAssetPrice.toDec()).mul(normalizationFactor)
);
const msg = {
place_limit: {
tick_id: parseInt(tickId.toString()),
order_direction: orderDirection,
quantity,
claim_bounty: CLAIM_BOUNTY,
},
};

return msg;
return msg;
} catch (error) {
console.error("Error attempting to place limit order", error);
return;
}
}, [
orderDirection,
priceState.price,
Expand Down

0 comments on commit 15df9a9

Please sign in to comment.