diff --git a/src/api/exchange/_methods/order.ts b/src/api/exchange/_methods/order.ts index c185de44..235d9725 100644 --- a/src/api/exchange/_methods/order.ts +++ b/src/api/exchange/_methods/order.ts @@ -71,15 +71,16 @@ export const OrderRequest = /* @__PURE__ */ (() => { * - `"na"`: Standard order without grouping. * - `"normalTpsl"`: TP/SL order with fixed size that doesn't adjust with position changes. * - `"positionTpsl"`: TP/SL order that adjusts proportionally with the position size. - * - `{ p: number }`: Order priority rate as a fraction `p / 1e8` (max `p = 80000`, i.e. 8 bps). - * Only valid when every order is IOC on a perp asset. + * - `{ p: number }`: Order priority rate as a fraction `p / 1e8`. + * Only valid when every order is on a non-outcome asset and either every order is IOC + * or every order is a non-reduce-only ALO. */ grouping: v.optional( v.union([ v.picklist(["na", "normalTpsl", "positionTpsl"]), v.object({ - /** Priority rate as a fraction `p / 1e8` (max `80000`, i.e. 8 bps). */ - p: v.pipe(UnsignedInteger, v.maxValue(80000)), + /** Priority rate as a fraction `p / 1e8`. */ + p: v.pipe(UnsignedInteger, v.maxValue(100_000_000)), }), ]), "na", diff --git a/tests/api/exchange/order.test.ts b/tests/api/exchange/order.test.ts index db9c1188..0c3bd514 100644 --- a/tests/api/exchange/order.test.ts +++ b/tests/api/exchange/order.test.ts @@ -32,7 +32,14 @@ runTest({ const params: OrderParameters[] = [ // resting | limit | Gtc | no cloid | grouping=default { - orders: [{ a: id, b: true, p: pxDown, s: sz, r: false, t: { limit: { tif: "Gtc" } } }], + orders: [{ + a: id, + b: true, + p: pxDown, + s: sz, + r: false, + t: { limit: { tif: "Gtc" } }, + }], }, // resting | limit | Alo | cloid { @@ -62,7 +69,14 @@ runTest({ }, // filled | limit | FrontendMarket | b=false | builder { - orders: [{ a: id, b: false, p: pxDown, s: sz, r: false, t: { limit: { tif: "FrontendMarket" } } }], + orders: [{ + a: id, + b: false, + p: pxDown, + s: sz, + r: false, + t: { limit: { tif: "FrontendMarket" } }, + }], grouping: "na", builder: { b: "0xe019d6167E7e324aEd003d94098496b6d986aB05", f: 1 }, }, @@ -95,19 +109,25 @@ runTest({ }, ]; - // Priority order: grouping={p:N} requires IOC on a perp asset; the temp account - // has no resting orders to match against, so this rejects with "Order could not - // immediately match". p=0 means no priority cost (no delegatable balance required). + // Priority order at the maximum rate: the fee is charged from undelegated staking + // balance, which a freshly created temp account does not have. const priorityParam: OrderParameters = { - orders: [{ a: id, b: true, p: pxDown, s: sz, r: false, t: { limit: { tif: "Ioc" } } }], - grouping: { p: 0 }, + orders: [{ + a: id, + b: true, + p: pxDown, + s: sz, + r: false, + t: { limit: { tif: "Ioc" } }, + }], + grouping: { p: 100_000_000 }, }; await assertRejects( async () => { await exchClient.order(priorityParam); }, ApiRequestError, - "Order could not immediately match", + "Insufficient delegatable balance for priority order", ); const data = await Promise.all(params.map((p) => exchClient.order(p)));