@orderly.network/hooks 1.5.12 → 1.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"baseCreator.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/baseCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,8BAAsB,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC;IAEvD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAE5E,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IA+BzC,YAAY,CACV,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC;IAsFxB,eAAe,CACb,KAAK,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC/B,EACD,MAAM,EAAE,eAAe,GACtB,WAAW;CAaf"}
1
+ {"version":3,"file":"baseCreator.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/baseCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,8BAAsB,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC;IAEvD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAE5E,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IA+BzC,YAAY,CACV,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC;IAmFxB,eAAe,CACb,KAAK,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC/B,EACD,MAAM,EAAE,eAAe,GACtB,WAAW;CAaf"}
@@ -53,21 +53,25 @@ export class BaseOrderCreator {
53
53
  };
54
54
  }
55
55
  }
56
- if (!!total) {
57
- const { quote_max, quote_min, quote_dp } = configs.symbol;
58
- const totalNumber = new Decimal(total);
59
- if (totalNumber.lt(quote_min)) {
60
- errors.total = {
61
- type: "min",
62
- message: `Quantity must be at least ${new Decimal(quote_min).todp(quote_dp)}`
63
- };
64
- } else if (totalNumber.gt(quote_max)) {
65
- errors.total = {
66
- type: "max",
67
- message: `Quantity should be less or equal than ${new Decimal(quote_max).todp(quote_dp)}`
68
- };
69
- }
70
- }
56
+ // if (!!total) {
57
+ // const { quote_max, quote_min, quote_dp } = configs.symbol;
58
+ // const totalNumber = new Decimal(total);
59
+ // if (totalNumber.lt(quote_min)) {
60
+ // errors.total = {
61
+ // type: "min",
62
+ // message: `Quantity must be at least ${new Decimal(quote_min).todp(
63
+ // quote_dp
64
+ // )}`,
65
+ // };
66
+ // } else if (totalNumber.gt(quote_max)) {
67
+ // errors.total = {
68
+ // type: "max",
69
+ // message: `Quantity should be less or equal than ${new Decimal(
70
+ // quote_max
71
+ // ).todp(quote_dp)}`,
72
+ // };
73
+ // }
74
+ // }
71
75
  const price = `${order_type}`.includes("MARKET") ? markPrice : order_price;
72
76
  const notionalHintStr = checkNotional(price, order_quantity, min_notional);
73
77
  if (notionalHintStr !== undefined && reduce_only !== true) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/orderCreator/baseCreator.ts"],"sourcesContent":["import { OrderEntity, OrderType } from \"@orderly.network/types\";\nimport {\n OrderCreator,\n OrderFormEntity,\n ValuesDepConfig,\n VerifyResult,\n} from \"./interface\";\nimport { Decimal } from \"@orderly.network/utils\";\nimport { checkNotional } from \"../../utils/createOrder\";\n\nexport abstract class BaseOrderCreator<T> implements OrderCreator<T> {\n abstract create(values: T, config?: ValuesDepConfig): T;\n\n abstract validate(values: T, config: ValuesDepConfig): Promise<VerifyResult>;\n\n baseOrder(data: OrderEntity): OrderEntity {\n const order: Pick<\n OrderEntity,\n | \"symbol\"\n | \"order_type\"\n | \"side\"\n | \"reduce_only\"\n | \"order_quantity\"\n | \"total\"\n | \"visible_quantity\"\n > = {\n symbol: data.symbol!,\n order_type:\n data.order_type === OrderType.LIMIT\n ? !!data.order_type_ext\n ? data.order_type_ext\n : data.order_type\n : data.order_type,\n side: data.side,\n reduce_only: data.reduce_only!,\n order_quantity: data.order_quantity!,\n total: data.total,\n };\n\n if (data.visible_quantity === 0) {\n order.visible_quantity = data.visible_quantity;\n }\n\n return order as OrderEntity;\n }\n\n baseValidate(\n values: OrderFormEntity,\n configs: ValuesDepConfig\n ): Promise<VerifyResult> {\n const errors: {\n [P in keyof OrderEntity]?: { type: string; message: string };\n } = {};\n\n const { maxQty, symbol, markPrice } = configs;\n\n // @ts-ignore\n let { order_quantity, total, order_price, reduce_only, order_type } = values;\n\n const { min_notional } = symbol;\n\n if (!order_quantity) {\n // calculate order_quantity from total\n if (total && order_price) {\n const { quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n const qty = totalNumber.dividedBy(order_price).toFixed(quote_dp);\n order_quantity = qty;\n }\n }\n\n if (!order_quantity) {\n errors.order_quantity = {\n type: \"required\",\n message: \"quantity is required\",\n };\n } else {\n // need to use MaxQty+base_max, base_min to compare\n const { base_min, quote_dp, base_dp } = configs.symbol;\n const qty = new Decimal(order_quantity);\n if (qty.lt(base_min)) {\n errors.order_quantity = {\n type: \"min\",\n message: `quantity must be greater than ${new Decimal(base_min).todp(\n base_dp\n )}`,\n };\n // errors.order_quantity = `quantity must be greater than ${base_min}`;\n } else if (qty.gt(maxQty)) {\n errors.order_quantity = {\n type: \"max\",\n message: `quantity must be less than ${new Decimal(maxQty).todp(\n base_dp\n )}`,\n };\n }\n }\n\n if (!!total) {\n const { quote_max, quote_min, quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n if (totalNumber.lt(quote_min)) {\n errors.total = {\n type: \"min\",\n message: `Quantity must be at least ${new Decimal(quote_min).todp(\n quote_dp\n )}`,\n };\n } else if (totalNumber.gt(quote_max)) {\n errors.total = {\n type: \"max\",\n message: `Quantity should be less or equal than ${new Decimal(\n quote_max\n ).todp(quote_dp)}`,\n };\n }\n }\n\n const price = `${order_type}`.includes(\"MARKET\") ? markPrice : order_price;\n const notionalHintStr = checkNotional(\n price,\n order_quantity,\n min_notional\n );\n\n if (notionalHintStr !== undefined && reduce_only !== true) {\n errors.total = {\n type: \"min\",\n message: notionalHintStr,\n };\n }\n\n return Promise.resolve(errors);\n }\n\n totalToQuantity(\n order: {\n order_quantity?: number | string;\n total?: string | number;\n order_price?: string | number;\n },\n config: ValuesDepConfig\n ): OrderEntity {\n // if order_quantity is not set but total is set, calculate order_quantity from total\n if (!order.order_quantity && order.total && order.order_price) {\n const { base_dp } = config.symbol;\n const totalNumber = new Decimal(order.total);\n const qty = totalNumber.div(order.order_price).toDecimalPlaces(base_dp);\n order.order_quantity = qty.toNumber();\n\n delete order.total;\n }\n\n return order as OrderEntity;\n }\n}\n"],"names":["OrderType","Decimal","checkNotional","BaseOrderCreator","baseOrder","data","order","symbol","order_type","LIMIT","order_type_ext","side","reduce_only","order_quantity","total","visible_quantity","baseValidate","values","configs","errors","maxQty","markPrice","order_price","min_notional","quote_dp","totalNumber","qty","dividedBy","toFixed","type","message","base_min","base_dp","lt","todp","gt","quote_max","quote_min","price","includes","notionalHintStr","undefined","Promise","resolve","totalToQuantity","config","div","toDecimalPlaces","toNumber"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAsBA,SAAS,QAAQ,yBAAyB;AAOhE,SAASC,OAAO,QAAQ,yBAAyB;AACjD,SAASC,aAAa,QAAQ,0BAA0B;AAExD,OAAO,MAAeC;IAKpBC,UAAUC,IAAiB,EAAe;QACxC,MAAMC,QASF;YACFC,QAAQF,KAAKE,MAAM;YACnBC,YACEH,KAAKG,UAAU,KAAKR,UAAUS,KAAK,GAC/B,CAAC,CAACJ,KAAKK,cAAc,GACnBL,KAAKK,cAAc,GACnBL,KAAKG,UAAU,GACjBH,KAAKG,UAAU;YACrBG,MAAMN,KAAKM,IAAI;YACfC,aAAaP,KAAKO,WAAW;YAC7BC,gBAAgBR,KAAKQ,cAAc;YACnCC,OAAOT,KAAKS,KAAK;QACnB;QAEA,IAAIT,KAAKU,gBAAgB,KAAK,GAAG;YAC/BT,MAAMS,gBAAgB,GAAGV,KAAKU,gBAAgB;QAChD;QAEA,OAAOT;IACT;IAEAU,aACEC,MAAuB,EACvBC,OAAwB,EACD;QACvB,MAAMC,SAEF,CAAC;QAEL,MAAM,EAAEC,MAAM,EAAEb,MAAM,EAAEc,SAAS,EAAE,GAAGH;QAEtC,aAAa;QACb,IAAI,EAAEL,cAAc,EAAEC,KAAK,EAAEQ,WAAW,EAAEV,WAAW,EAAEJ,UAAU,EAAE,GAAGS;QAEtE,MAAM,EAAEM,YAAY,EAAE,GAAGhB;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GAAG;oBACbe,MAAM;oBACNC,SAAS,CAAC,sCAAsC,EAAE,IAAI7B,QACpDmC,WACAF,IAAI,CAACV,UAAU,CAAC;gBACpB;YACF;QACF;QAEA,MAAMc,QAAQ,CAAC,EAAE9B,WAAW,CAAC,CAAC+B,QAAQ,CAAC,YAAYlB,YAAYC;QAC/D,MAAMkB,kBAAkBtC,cACtBoC,OACAzB,gBACAU;QAGF,IAAIiB,oBAAoBC,aAAa7B,gBAAgB,MAAM;YACzDO,OAAOL,KAAK,GAAG;gBACbe,MAAM;gBACNC,SAASU;YACX;QACF;QAEA,OAAOE,QAAQC,OAAO,CAACxB;IACzB;IAEAyB,gBACEtC,KAIC,EACDuC,MAAuB,EACV;QACb,qFAAqF;QACrF,IAAI,CAACvC,MAAMO,cAAc,IAAIP,MAAMQ,KAAK,IAAIR,MAAMgB,WAAW,EAAE;YAC7D,MAAM,EAAEU,OAAO,EAAE,GAAGa,OAAOtC,MAAM;YACjC,MAAMkB,cAAc,IAAIxB,QAAQK,MAAMQ,KAAK;YAC3C,MAAMY,MAAMD,YAAYqB,GAAG,CAACxC,MAAMgB,WAAW,EAAEyB,eAAe,CAACf;YAC/D1B,MAAMO,cAAc,GAAGa,IAAIsB,QAAQ;YAEnC,OAAO1C,MAAMQ,KAAK;QACpB;QAEA,OAAOR;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/services/orderCreator/baseCreator.ts"],"sourcesContent":["import { OrderEntity, OrderType } from \"@orderly.network/types\";\nimport {\n OrderCreator,\n OrderFormEntity,\n ValuesDepConfig,\n VerifyResult,\n} from \"./interface\";\nimport { Decimal } from \"@orderly.network/utils\";\nimport { checkNotional } from \"../../utils/createOrder\";\n\nexport abstract class BaseOrderCreator<T> implements OrderCreator<T> {\n abstract create(values: T, config?: ValuesDepConfig): T;\n\n abstract validate(values: T, config: ValuesDepConfig): Promise<VerifyResult>;\n\n baseOrder(data: OrderEntity): OrderEntity {\n const order: Pick<\n OrderEntity,\n | \"symbol\"\n | \"order_type\"\n | \"side\"\n | \"reduce_only\"\n | \"order_quantity\"\n | \"total\"\n | \"visible_quantity\"\n > = {\n symbol: data.symbol!,\n order_type:\n data.order_type === OrderType.LIMIT\n ? !!data.order_type_ext\n ? data.order_type_ext\n : data.order_type\n : data.order_type,\n side: data.side,\n reduce_only: data.reduce_only!,\n order_quantity: data.order_quantity!,\n total: data.total,\n };\n\n if (data.visible_quantity === 0) {\n order.visible_quantity = data.visible_quantity;\n }\n\n return order as OrderEntity;\n }\n\n baseValidate(\n values: OrderFormEntity,\n configs: ValuesDepConfig\n ): Promise<VerifyResult> {\n const errors: {\n [P in keyof OrderEntity]?: { type: string; message: string };\n } = {};\n\n const { maxQty, symbol, markPrice } = configs;\n\n // @ts-ignore\n let { order_quantity, total, order_price, reduce_only, order_type } =\n values;\n\n const { min_notional } = symbol;\n\n if (!order_quantity) {\n // calculate order_quantity from total\n if (total && order_price) {\n const { quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n const qty = totalNumber.dividedBy(order_price).toFixed(quote_dp);\n order_quantity = qty;\n }\n }\n\n if (!order_quantity) {\n errors.order_quantity = {\n type: \"required\",\n message: \"quantity is required\",\n };\n } else {\n // need to use MaxQty+base_max, base_min to compare\n const { base_min, quote_dp, base_dp } = configs.symbol;\n const qty = new Decimal(order_quantity);\n if (qty.lt(base_min)) {\n errors.order_quantity = {\n type: \"min\",\n message: `quantity must be greater than ${new Decimal(base_min).todp(\n base_dp\n )}`,\n };\n // errors.order_quantity = `quantity must be greater than ${base_min}`;\n } else if (qty.gt(maxQty)) {\n errors.order_quantity = {\n type: \"max\",\n message: `quantity must be less than ${new Decimal(maxQty).todp(\n base_dp\n )}`,\n };\n }\n }\n\n // if (!!total) {\n // const { quote_max, quote_min, quote_dp } = configs.symbol;\n // const totalNumber = new Decimal(total);\n // if (totalNumber.lt(quote_min)) {\n // errors.total = {\n // type: \"min\",\n // message: `Quantity must be at least ${new Decimal(quote_min).todp(\n // quote_dp\n // )}`,\n // };\n // } else if (totalNumber.gt(quote_max)) {\n // errors.total = {\n // type: \"max\",\n // message: `Quantity should be less or equal than ${new Decimal(\n // quote_max\n // ).todp(quote_dp)}`,\n // };\n // }\n // }\n\n const price = `${order_type}`.includes(\"MARKET\") ? markPrice : order_price;\n const notionalHintStr = checkNotional(price, order_quantity, min_notional);\n\n if (notionalHintStr !== undefined && reduce_only !== true) {\n errors.total = {\n type: \"min\",\n message: notionalHintStr,\n };\n }\n\n return Promise.resolve(errors);\n }\n\n totalToQuantity(\n order: {\n order_quantity?: number | string;\n total?: string | number;\n order_price?: string | number;\n },\n config: ValuesDepConfig\n ): OrderEntity {\n // if order_quantity is not set but total is set, calculate order_quantity from total\n if (!order.order_quantity && order.total && order.order_price) {\n const { base_dp } = config.symbol;\n const totalNumber = new Decimal(order.total);\n const qty = totalNumber.div(order.order_price).toDecimalPlaces(base_dp);\n order.order_quantity = qty.toNumber();\n\n delete order.total;\n }\n\n return order as OrderEntity;\n }\n}\n"],"names":["OrderType","Decimal","checkNotional","BaseOrderCreator","baseOrder","data","order","symbol","order_type","LIMIT","order_type_ext","side","reduce_only","order_quantity","total","visible_quantity","baseValidate","values","configs","errors","maxQty","markPrice","order_price","min_notional","quote_dp","totalNumber","qty","dividedBy","toFixed","type","message","base_min","base_dp","lt","todp","gt","price","includes","notionalHintStr","undefined","Promise","resolve","totalToQuantity","config","div","toDecimalPlaces","toNumber"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAsBA,SAAS,QAAQ,yBAAyB;AAOhE,SAASC,OAAO,QAAQ,yBAAyB;AACjD,SAASC,aAAa,QAAQ,0BAA0B;AAExD,OAAO,MAAeC;IAKpBC,UAAUC,IAAiB,EAAe;QACxC,MAAMC,QASF;YACFC,QAAQF,KAAKE,MAAM;YACnBC,YACEH,KAAKG,UAAU,KAAKR,U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5,6 +5,6 @@ declare global {
5
5
  };
6
6
  }
7
7
  }
8
- declare const _default: "1.5.12";
8
+ declare const _default: "1.5.13";
9
9
  export default _default;
10
10
  //# sourceMappingURL=version.d.ts.map
package/esm/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  if (typeof window !== 'undefined') {
2
2
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
3
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.5.12";
3
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.5.13";
4
4
  }
5
- export default "1.5.12";
5
+ export default "1.5.13";
6
6
 
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["\ndeclare global {\n interface Window {\n __ORDERLY_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif(typeof window !== 'undefined') {\n window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};\n window.__ORDERLY_VERSION__[\"@orderly.network/hooks\"] = \"1.5.12\";\n};\n\nexport default \"1.5.12\";\n"],"names":["window","__ORDERLY_VERSION__"],"rangeMappings":";;;;","mappings":"AAQA,IAAG,OAAOA,WAAW,aAAa;IAC9BA,OAAOC,mBAAmB,GAAGD,OAAOC,mBAAmB,IAAI,CAAC;IAC5DD,OAAOC,mBAAmB,CAAC,yBAAyB,GAAG;AAC3D;AAEA,eAAe,SAAS"}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["\ndeclare global {\n interface Window {\n __ORDERLY_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif(typeof window !== 'undefined') {\n window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};\n window.__ORDERLY_VERSION__[\"@orderly.network/hooks\"] = \"1.5.13\";\n};\n\nexport default \"1.5.13\";\n"],"names":["window","__ORDERLY_VERSION__"],"rangeMappings":";;;;","mappings":"AAQA,IAAG,OAAOA,WAAW,aAAa;IAC9BA,OAAOC,mBAAmB,GAAGD,OAAOC,mBAAmB,IAAI,CAAC;IAC5DD,OAAOC,mBAAmB,CAAC,yBAAyB,GAAG;AAC3D;AAEA,eAAe,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"baseCreator.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/baseCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,8BAAsB,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC;IAEvD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAE5E,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IA+BzC,YAAY,CACV,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC;IAsFxB,eAAe,CACb,KAAK,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC/B,EACD,MAAM,EAAE,eAAe,GACtB,WAAW;CAaf"}
1
+ {"version":3,"file":"baseCreator.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/baseCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,8BAAsB,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC;IAEvD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAE5E,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IA+BzC,YAAY,CACV,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC;IAmFxB,eAAe,CACb,KAAK,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC/B,EACD,MAAM,EAAE,eAAe,GACtB,WAAW;CAaf"}
@@ -63,21 +63,25 @@ class BaseOrderCreator {
63
63
  };
64
64
  }
65
65
  }
66
- if (!!total) {
67
- const { quote_max, quote_min, quote_dp } = configs.symbol;
68
- const totalNumber = new _utils.Decimal(total);
69
- if (totalNumber.lt(quote_min)) {
70
- errors.total = {
71
- type: "min",
72
- message: `Quantity must be at least ${new _utils.Decimal(quote_min).todp(quote_dp)}`
73
- };
74
- } else if (totalNumber.gt(quote_max)) {
75
- errors.total = {
76
- type: "max",
77
- message: `Quantity should be less or equal than ${new _utils.Decimal(quote_max).todp(quote_dp)}`
78
- };
79
- }
80
- }
66
+ // if (!!total) {
67
+ // const { quote_max, quote_min, quote_dp } = configs.symbol;
68
+ // const totalNumber = new Decimal(total);
69
+ // if (totalNumber.lt(quote_min)) {
70
+ // errors.total = {
71
+ // type: "min",
72
+ // message: `Quantity must be at least ${new Decimal(quote_min).todp(
73
+ // quote_dp
74
+ // )}`,
75
+ // };
76
+ // } else if (totalNumber.gt(quote_max)) {
77
+ // errors.total = {
78
+ // type: "max",
79
+ // message: `Quantity should be less or equal than ${new Decimal(
80
+ // quote_max
81
+ // ).todp(quote_dp)}`,
82
+ // };
83
+ // }
84
+ // }
81
85
  const price = `${order_type}`.includes("MARKET") ? markPrice : order_price;
82
86
  const notionalHintStr = (0, _createOrder.checkNotional)(price, order_quantity, min_notional);
83
87
  if (notionalHintStr !== undefined && reduce_only !== true) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/orderCreator/baseCreator.ts"],"sourcesContent":["import { OrderEntity, OrderType } from \"@orderly.network/types\";\nimport {\n OrderCreator,\n OrderFormEntity,\n ValuesDepConfig,\n VerifyResult,\n} from \"./interface\";\nimport { Decimal } from \"@orderly.network/utils\";\nimport { checkNotional } from \"../../utils/createOrder\";\n\nexport abstract class BaseOrderCreator<T> implements OrderCreator<T> {\n abstract create(values: T, config?: ValuesDepConfig): T;\n\n abstract validate(values: T, config: ValuesDepConfig): Promise<VerifyResult>;\n\n baseOrder(data: OrderEntity): OrderEntity {\n const order: Pick<\n OrderEntity,\n | \"symbol\"\n | \"order_type\"\n | \"side\"\n | \"reduce_only\"\n | \"order_quantity\"\n | \"total\"\n | \"visible_quantity\"\n > = {\n symbol: data.symbol!,\n order_type:\n data.order_type === OrderType.LIMIT\n ? !!data.order_type_ext\n ? data.order_type_ext\n : data.order_type\n : data.order_type,\n side: data.side,\n reduce_only: data.reduce_only!,\n order_quantity: data.order_quantity!,\n total: data.total,\n };\n\n if (data.visible_quantity === 0) {\n order.visible_quantity = data.visible_quantity;\n }\n\n return order as OrderEntity;\n }\n\n baseValidate(\n values: OrderFormEntity,\n configs: ValuesDepConfig\n ): Promise<VerifyResult> {\n const errors: {\n [P in keyof OrderEntity]?: { type: string; message: string };\n } = {};\n\n const { maxQty, symbol, markPrice } = configs;\n\n // @ts-ignore\n let { order_quantity, total, order_price, reduce_only, order_type } = values;\n\n const { min_notional } = symbol;\n\n if (!order_quantity) {\n // calculate order_quantity from total\n if (total && order_price) {\n const { quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n const qty = totalNumber.dividedBy(order_price).toFixed(quote_dp);\n order_quantity = qty;\n }\n }\n\n if (!order_quantity) {\n errors.order_quantity = {\n type: \"required\",\n message: \"quantity is required\",\n };\n } else {\n // need to use MaxQty+base_max, base_min to compare\n const { base_min, quote_dp, base_dp } = configs.symbol;\n const qty = new Decimal(order_quantity);\n if (qty.lt(base_min)) {\n errors.order_quantity = {\n type: \"min\",\n message: `quantity must be greater than ${new Decimal(base_min).todp(\n base_dp\n )}`,\n };\n // errors.order_quantity = `quantity must be greater than ${base_min}`;\n } else if (qty.gt(maxQty)) {\n errors.order_quantity = {\n type: \"max\",\n message: `quantity must be less than ${new Decimal(maxQty).todp(\n base_dp\n )}`,\n };\n }\n }\n\n if (!!total) {\n const { quote_max, quote_min, quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n if (totalNumber.lt(quote_min)) {\n errors.total = {\n type: \"min\",\n message: `Quantity must be at least ${new Decimal(quote_min).todp(\n quote_dp\n )}`,\n };\n } else if (totalNumber.gt(quote_max)) {\n errors.total = {\n type: \"max\",\n message: `Quantity should be less or equal than ${new Decimal(\n quote_max\n ).todp(quote_dp)}`,\n };\n }\n }\n\n const price = `${order_type}`.includes(\"MARKET\") ? markPrice : order_price;\n const notionalHintStr = checkNotional(\n price,\n order_quantity,\n min_notional\n );\n\n if (notionalHintStr !== undefined && reduce_only !== true) {\n errors.total = {\n type: \"min\",\n message: notionalHintStr,\n };\n }\n\n return Promise.resolve(errors);\n }\n\n totalToQuantity(\n order: {\n order_quantity?: number | string;\n total?: string | number;\n order_price?: string | number;\n },\n config: ValuesDepConfig\n ): OrderEntity {\n // if order_quantity is not set but total is set, calculate order_quantity from total\n if (!order.order_quantity && order.total && order.order_price) {\n const { base_dp } = config.symbol;\n const totalNumber = new Decimal(order.total);\n const qty = totalNumber.div(order.order_price).toDecimalPlaces(base_dp);\n order.order_quantity = qty.toNumber();\n\n delete order.total;\n }\n\n return order as OrderEntity;\n }\n}\n"],"names":["BaseOrderCreator","baseOrder","data","order","symbol","order_type","OrderType","LIMIT","order_type_ext","side","reduce_only","order_quantity","total","visible_quantity","baseValidate","values","configs","errors","maxQty","markPrice","order_price","min_notional","quote_dp","totalNumber","Decimal","qty","dividedBy","toFixed","type","message","base_min","base_dp","lt","todp","gt","quote_max","quote_min","price","includes","notionalHintStr","checkNotional","undefined","Promise","resolve","totalToQuantity","config","div","toDecimalPlaces","toNumber"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAUsBA;;;eAAAA;;;uBAViB;uBAOf;6BACM;AAEvB,MAAeA;IAKpBC,UAAUC,IAAiB,EAAe;QACxC,MAAMC,QASF;YACFC,QAAQF,KAAKE,MAAM;YACnBC,YACEH,KAAKG,UAAU,KAAKC,gBAAS,CAACC,KAAK,GAC/B,CAAC,CAACL,KAAKM,cAAc,GACnBN,KAAKM,cAAc,GACnBN,KAAKG,UAAU,GACjBH,KAAKG,UAAU;YACrBI,MAAMP,KAAKO,IAAI;YACfC,aAAaR,KAAKQ,WAAW;YAC7BC,gBAAgBT,KAAKS,cAAc;YACnCC,OAAOV,KAAKU,KAAK;QACnB;QAEA,IAAIV,KAAKW,gBAAgB,KAAK,GAAG;YAC/BV,MAAMU,gBAAgB,GAAGX,KAAKW,gBAAgB;QAChD;QAEA,OAAOV;IACT;IAEAW,aACEC,MAAuB,EACvBC,OAAwB,EACD;QACvB,MAAMC,SAEF,CAAC;QAEL,MAAM,EAAEC,MAAM,EAAEd,MAAM,EAAEe,SAAS,EAAE,GAAGH;QAEtC,aAAa;QACb,IAAI,EAAEL,cAAc,EAAEC,KAAK,EAAEQ,WAAW,EAAEV,WAAW,EAAEL,UAAU,EAAE,GAAGU;QAEtE,MAAM,EAAEM,YAAY,EAAE,GAAGjB;QAEzB,IAAI,CAACO,gBAAg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bgB,MAAM;oBACNC,SAAS,CAAC,sCAAsC,EAAE,IAAIL,cAAO,CAC3DW,WACAF,IAAI,CAACX,UAAU,CAAC;gBACpB;YACF;QACF;QAEA,MAAMe,QAAQ,CAAC,EAAEhC,WAAW,CAAC,CAACiC,QAAQ,CAAC,YAAYnB,YAAYC;QAC/D,MAAMmB,kBAAkBC,IAAAA,0BAAa,EACnCH,OACA1B,gBACAU;QAGF,IAAIkB,oBAAoBE,aAAa/B,gBAAgB,MAAM;YACzDO,OAAOL,KAAK,GAAG;gBACbgB,MAAM;gBACNC,SAASU;YACX;QACF;QAEA,OAAOG,QAAQC,OAAO,CAAC1B;IACzB;IAEA2B,gBACEzC,KAIC,EACD0C,MAAuB,EACV;QACb,qFAAqF;QACrF,IAAI,CAAC1C,MAAMQ,cAAc,IAAIR,MAAMS,KAAK,IAAIT,MAAMiB,WAAW,EAAE;YAC7D,MAAM,EAAEW,OAAO,EAAE,GAAGc,OAAOzC,MAAM;YACjC,MAAMmB,cAAc,IAAIC,cAAO,CAACrB,MAAMS,KAAK;YAC3C,MAAMa,MAAMF,YAAYuB,GAAG,CAAC3C,MAAMiB,WAAW,EAAE2B,eAAe,CAAChB;YAC/D5B,MAAMQ,cAAc,GAAGc,IAAIuB,QAAQ;YAEnC,OAAO7C,MAAMS,KAAK;QACpB;QAEA,OAAOT;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/services/orderCreator/baseCreator.ts"],"sourcesContent":["import { OrderEntity, OrderType } from \"@orderly.network/types\";\nimport {\n OrderCreator,\n OrderFormEntity,\n ValuesDepConfig,\n VerifyResult,\n} from \"./interface\";\nimport { Decimal } from \"@orderly.network/utils\";\nimport { checkNotional } from \"../../utils/createOrder\";\n\nexport abstract class BaseOrderCreator<T> implements OrderCreator<T> {\n abstract create(values: T, config?: ValuesDepConfig): T;\n\n abstract validate(values: T, config: ValuesDepConfig): Promise<VerifyResult>;\n\n baseOrder(data: OrderEntity): OrderEntity {\n const order: Pick<\n OrderEntity,\n | \"symbol\"\n | \"order_type\"\n | \"side\"\n | \"reduce_only\"\n | \"order_quantity\"\n | \"total\"\n | \"visible_quantity\"\n > = {\n symbol: data.symbol!,\n order_type:\n data.order_type === OrderType.LIMIT\n ? !!data.order_type_ext\n ? data.order_type_ext\n : data.order_type\n : data.order_type,\n side: data.side,\n reduce_only: data.reduce_only!,\n order_quantity: data.order_quantity!,\n total: data.total,\n };\n\n if (data.visible_quantity === 0) {\n order.visible_quantity = data.visible_quantity;\n }\n\n return order as OrderEntity;\n }\n\n baseValidate(\n values: OrderFormEntity,\n configs: ValuesDepConfig\n ): Promise<VerifyResult> {\n const errors: {\n [P in keyof OrderEntity]?: { type: string; message: string };\n } = {};\n\n const { maxQty, symbol, markPrice } = configs;\n\n // @ts-ignore\n let { order_quantity, total, order_price, reduce_only, order_type } =\n values;\n\n const { min_notional } = symbol;\n\n if (!order_quantity) {\n // calculate order_quantity from total\n if (total && order_price) {\n const { quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n const qty = totalNumber.dividedBy(order_price).toFixed(quote_dp);\n order_quantity = qty;\n }\n }\n\n if (!order_quantity) {\n errors.order_quantity = {\n type: \"required\",\n message: \"quantity is required\",\n };\n } else {\n // need to use MaxQty+base_max, base_min to compare\n const { base_min, quote_dp, base_dp } = configs.symbol;\n const qty = new Decimal(order_quantity);\n if (qty.lt(base_min)) {\n errors.order_quantity = {\n type: \"min\",\n message: `quantity must be greater than ${new Decimal(base_min).todp(\n base_dp\n )}`,\n };\n // errors.order_quantity = `quantity must be greater than ${base_min}`;\n } else if (qty.gt(maxQty)) {\n errors.order_quantity = {\n type: \"max\",\n message: `quantity must be less than ${new Decimal(maxQty).todp(\n base_dp\n )}`,\n };\n }\n }\n\n // if (!!total) {\n // const { quote_max, quote_min, quote_dp } = configs.symbol;\n // const totalNumber = new Decimal(total);\n // if (totalNumber.lt(quote_min)) {\n // errors.total = {\n // type: \"min\",\n // message: `Quantity must be at least ${new Decimal(quote_min).todp(\n // quote_dp\n // )}`,\n // };\n // } else if (totalNumber.gt(quote_max)) {\n // errors.total = {\n // type: \"max\",\n // message: `Quantity should be less or equal than ${new Decimal(\n // quote_max\n // ).todp(quote_dp)}`,\n // };\n // }\n // }\n\n const price = `${order_type}`.includes(\"MARKET\") ? markPrice : order_price;\n const notionalHintStr = checkNotional(price, order_quantity, min_notional);\n\n if (notionalHintStr !== undefined && reduce_only !== true) {\n errors.total = {\n type: \"min\",\n message: notionalHintStr,\n };\n }\n\n return Promise.resolve(errors);\n }\n\n totalToQuantity(\n order: {\n order_quantity?: number | string;\n total?: string | number;\n order_price?: string | number;\n },\n config: ValuesDepConfig\n ): OrderEntity {\n // if order_quantity is not set but total is set, calculate order_quantity from total\n if (!order.order_quantity && order.total && order.order_price) {\n const { base_dp } = config.symbol;\n const totalNumber = new Decimal(order.total);\n const qty = totalNumber.div(order.order_price).toDecimalPlaces(base_dp);\n order.order_quantity = qty.toNumber();\n\n delete order.total;\n }\n\n return order as OrderEntity;\n }\n}\n"],"names":["BaseOrderCreator","baseOrder","data","order","symbol","order_type","OrderType","LIMIT","order_type_ext","side","reduce_only","order_quantity","total","visible_quantity","baseValidate","values","configs","errors","maxQty","markPrice","order_price","min_notional","quote_dp","totalNumber","Decimal","qty","dividedBy","toFixed","type","message","base_min","base_dp","lt","todp","gt","price","includes","notionalHintStr","checkNotional","undefined","Promise","resolve","totalToQuantity","config","div","toDecimalPlaces","toNumber"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAUsBA;;;eAAAA;;;uBAViB;uBAOf;6BACM;AAEvB,MAAeA;IAKpBC,UAAUC,IAAiB,EAAe;QACxC,MAAMC,QASF;YACFC,QAAQF,KAAKE,MAAM;YACnBC,YACEH,KAAKG,UAAU,KAAKC,gBAAS,CAACC,KAAK,GAC/B,CAAC,CAAC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 +5,6 @@ declare global {
5
5
  };
6
6
  }
7
7
  }
8
- declare const _default: "1.5.12";
8
+ declare const _default: "1.5.13";
9
9
  export default _default;
10
10
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  if (typeof window !== 'undefined') {
12
12
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
13
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.5.12";
13
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.5.13";
14
14
  }
15
- const _default = "1.5.12";
15
+ const _default = "1.5.13";
16
16
 
17
17
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["\ndeclare global {\n interface Window {\n __ORDERLY_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif(typeof window !== 'undefined') {\n window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};\n window.__ORDERLY_VERSION__[\"@orderly.network/hooks\"] = \"1.5.12\";\n};\n\nexport default \"1.5.12\";\n"],"names":["window","__ORDERLY_VERSION__"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BAaA;;;eAAA;;;AALA,IAAG,OAAOA,WAAW,aAAa;IAC9BA,OAAOC,mBAAmB,GAAGD,OAAOC,mBAAmB,IAAI,CAAC;IAC5DD,OAAOC,mBAAmB,CAAC,yBAAyB,GAAG;AAC3D;MAEA,WAAe"}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["\ndeclare global {\n interface Window {\n __ORDERLY_VERSION__?: {\n [key: string]: string;\n };\n }\n}\nif(typeof window !== 'undefined') {\n window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};\n window.__ORDERLY_VERSION__[\"@orderly.network/hooks\"] = \"1.5.13\";\n};\n\nexport default \"1.5.13\";\n"],"names":["window","__ORDERLY_VERSION__"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BAaA;;;eAAA;;;AALA,IAAG,OAAOA,WAAW,aAAa;IAC9BA,OAAOC,mBAAmB,GAAGD,OAAOC,mBAAmB,IAAI,CAAC;IAC5DD,OAAOC,mBAAmB,CAAC,yBAAyB,GAAG;AAC3D;MAEA,WAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orderly.network/hooks",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -33,7 +33,7 @@
33
33
  "tsup": "^7.1.0",
34
34
  "typedoc": "^0.26.5",
35
35
  "typescript": "^5.1.6",
36
- "tsconfig": "0.3.12"
36
+ "tsconfig": "0.3.13"
37
37
  },
38
38
  "dependencies": {
39
39
  "@akamfoad/qr": "^0.4.0",
@@ -41,11 +41,11 @@
41
41
  "swr": "2.2.4",
42
42
  "use-constant": "^1.1.1",
43
43
  "use-debounce": "^9.0.4",
44
- "@orderly.network/core": "1.5.12",
45
- "@orderly.network/net": "1.5.12",
46
- "@orderly.network/types": "1.5.12",
47
- "@orderly.network/utils": "1.5.12",
48
- "@orderly.network/perp": "3.3.12"
44
+ "@orderly.network/utils": "1.5.13",
45
+ "@orderly.network/perp": "3.3.13",
46
+ "@orderly.network/net": "1.5.13",
47
+ "@orderly.network/core": "1.5.13",
48
+ "@orderly.network/types": "1.5.13"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"