Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.
Open
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
16 changes: 8 additions & 8 deletions src/order-builder/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ export const getMarketOrderRawAmounts = (
if (side === Side.BUY) {
const rawMakerAmt = roundDown(amount, roundConfig.size);
let rawTakerAmt = rawMakerAmt / rawPrice;
if (decimalPlaces(rawTakerAmt) > roundConfig.amount) {
rawTakerAmt = roundUp(rawTakerAmt, roundConfig.amount + 4);
if (decimalPlaces(rawTakerAmt) > roundConfig.amount) {
rawTakerAmt = roundDown(rawTakerAmt, roundConfig.amount);
if (decimalPlaces(rawTakerAmt) > roundConfig.size) {
rawTakerAmt = roundUp(rawTakerAmt, roundConfig.size + 4);
if (decimalPlaces(rawTakerAmt) > roundConfig.size) {
rawTakerAmt = roundDown(rawTakerAmt, roundConfig.size);
}
}
return {
Expand All @@ -217,10 +217,10 @@ export const getMarketOrderRawAmounts = (
} else {
const rawMakerAmt = roundDown(amount, roundConfig.size);
let rawTakerAmt = rawMakerAmt * rawPrice;
if (decimalPlaces(rawTakerAmt) > roundConfig.amount) {
rawTakerAmt = roundUp(rawTakerAmt, roundConfig.amount + 4);
if (decimalPlaces(rawTakerAmt) > roundConfig.amount) {
rawTakerAmt = roundDown(rawTakerAmt, roundConfig.amount);
if (decimalPlaces(rawTakerAmt) > roundConfig.size) {
rawTakerAmt = roundUp(rawTakerAmt, roundConfig.size + 4);
if (decimalPlaces(rawTakerAmt) > roundConfig.size) {
rawTakerAmt = roundDown(rawTakerAmt, roundConfig.size);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SELL orders use wrong rounding config for collateral

High Severity

For SELL market orders, rawTakerAmt is calculated as rawMakerAmt * rawPrice, which represents a collateral amount (not token size). The change incorrectly uses roundConfig.size for collateral precision when it should use roundConfig.amount. This is inconsistent with getOrderRawAmounts where SELL orders correctly use roundConfig.amount for rawTakerAmt collateral. Using size (2 decimals) instead of amount (4+ decimals) causes premature rounding of collateral amounts.

Fix in Cursor Fix in Web

}
}

Expand Down