@reyaxyz/common 0.310.3 → 0.311.0

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.
package/README.md CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-20.39%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-18%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-10.26%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-22.11%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-20.49%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-18.18%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-10.31%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-22.23%25-red.svg?style=flat) |
10
10
 
@@ -1,28 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calculateMaxPriceLimit = exports.calculatePriceLimitForTrade = void 0;
7
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
3
+ exports.calculateMaxPriceLimit = void 0;
8
4
  var ethers_1 = require("ethers");
9
- // todo: need the ability to supply custom slippage or use a more conservative default for the slippage tolerance
10
- function calculatePriceLimitForTrade(orderPrice, amount, factor) {
11
- if (factor === void 0) { factor = 100; }
12
- // Ensure orderPrice is BigInt
13
- var orderPriceBigInt = (0, bignumber_js_1.default)(orderPrice);
14
- // Calculate 1% (or provided factor) of the order price
15
- var offset = orderPriceBigInt.div(factor);
16
- // Determine if the amount is positive or negative and adjust the price accordingly
17
- if (amount > 0) {
18
- // Trade is long, so add
19
- return BigInt((0, bignumber_js_1.default)(orderPriceBigInt).plus(offset).times(1e18).toFixed(0));
20
- }
21
- else {
22
- return BigInt((0, bignumber_js_1.default)(orderPriceBigInt).minus(offset).times(1e18).toFixed(0));
23
- }
24
- }
25
- exports.calculatePriceLimitForTrade = calculatePriceLimitForTrade;
26
5
  function calculateMaxPriceLimit(isLong) {
27
6
  // Determine if the amount is positive or negative and adjust the price accordingly
28
7
  if (isLong) {
@@ -1 +1 @@
1
- {"version":3,"file":"trade.js","sourceRoot":"/","sources":["transactions/trade.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqC;AACrC,iCAAoC;AAEpC,iHAAiH;AACjH,SAAgB,2BAA2B,CACzC,UAAkB,EAClB,MAAc,EACd,MAAY;IAAZ,uBAAA,EAAA,YAAY;IAEZ,8BAA8B;IAC9B,IAAM,gBAAgB,GAAG,IAAA,sBAAS,EAAC,UAAU,CAAC,CAAC;IAE/C,uDAAuD;IACvD,IAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE5C,mFAAmF;IACnF,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,wBAAwB;QACxB,OAAO,MAAM,CACX,IAAA,sBAAS,EAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAChE,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CACX,IAAA,sBAAS,EAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACjE,CAAC;IACJ,CAAC;AACH,CAAC;AAtBD,kEAsBC;AAED,SAAgB,sBAAsB,CAAC,MAAe;IACpD,mFAAmF;IACnF,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,mBAAU,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAPD,wDAOC","sourcesContent":["import BigNumber from 'bignumber.js';\nimport { MaxUint256 } from 'ethers';\n\n// todo: need the ability to supply custom slippage or use a more conservative default for the slippage tolerance\nexport function calculatePriceLimitForTrade(\n orderPrice: number,\n amount: number,\n factor = 100,\n): bigint {\n // Ensure orderPrice is BigInt\n const orderPriceBigInt = BigNumber(orderPrice);\n\n // Calculate 1% (or provided factor) of the order price\n const offset = orderPriceBigInt.div(factor);\n\n // Determine if the amount is positive or negative and adjust the price accordingly\n if (amount > 0) {\n // Trade is long, so add\n return BigInt(\n BigNumber(orderPriceBigInt).plus(offset).times(1e18).toFixed(0),\n );\n } else {\n return BigInt(\n BigNumber(orderPriceBigInt).minus(offset).times(1e18).toFixed(0),\n );\n }\n}\n\nexport function calculateMaxPriceLimit(isLong: boolean): bigint {\n // Determine if the amount is positive or negative and adjust the price accordingly\n if (isLong) {\n return MaxUint256;\n } else {\n return BigInt(0);\n }\n}\n"]}
1
+ {"version":3,"file":"trade.js","sourceRoot":"/","sources":["transactions/trade.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AAEpC,SAAgB,sBAAsB,CAAC,MAAe;IACpD,mFAAmF;IACnF,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,mBAAU,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAPD,wDAOC","sourcesContent":["import { MaxUint256 } from 'ethers';\n\nexport function calculateMaxPriceLimit(isLong: boolean): bigint {\n // Determine if the amount is positive or negative and adjust the price accordingly\n if (isLong) {\n return MaxUint256;\n } else {\n return BigInt(0);\n }\n}\n"]}
@@ -1,3 +1,2 @@
1
- export declare function calculatePriceLimitForTrade(orderPrice: number, amount: number, factor?: number): bigint;
2
1
  export declare function calculateMaxPriceLimit(isLong: boolean): bigint;
3
2
  //# sourceMappingURL=trade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trade.d.ts","sourceRoot":"/","sources":["transactions/trade.ts"],"names":[],"mappings":"AAIA,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,SAAM,GACX,MAAM,CAkBR;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAO9D"}
1
+ {"version":3,"file":"trade.d.ts","sourceRoot":"/","sources":["transactions/trade.ts"],"names":[],"mappings":"AAEA,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAO9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/common",
3
- "version": "0.310.3",
3
+ "version": "0.311.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -44,5 +44,5 @@
44
44
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
45
45
  },
46
46
  "packageManager": "pnpm@8.3.1",
47
- "gitHead": "fd97edccdc28ca41655e1290f3b3f43d6f3a7e6e"
47
+ "gitHead": "820bf1d931672522440894ba3b13568bc7ea753e"
48
48
  }
@@ -1,31 +1,5 @@
1
- import BigNumber from 'bignumber.js';
2
1
  import { MaxUint256 } from 'ethers';
3
2
 
4
- // todo: need the ability to supply custom slippage or use a more conservative default for the slippage tolerance
5
- export function calculatePriceLimitForTrade(
6
- orderPrice: number,
7
- amount: number,
8
- factor = 100,
9
- ): bigint {
10
- // Ensure orderPrice is BigInt
11
- const orderPriceBigInt = BigNumber(orderPrice);
12
-
13
- // Calculate 1% (or provided factor) of the order price
14
- const offset = orderPriceBigInt.div(factor);
15
-
16
- // Determine if the amount is positive or negative and adjust the price accordingly
17
- if (amount > 0) {
18
- // Trade is long, so add
19
- return BigInt(
20
- BigNumber(orderPriceBigInt).plus(offset).times(1e18).toFixed(0),
21
- );
22
- } else {
23
- return BigInt(
24
- BigNumber(orderPriceBigInt).minus(offset).times(1e18).toFixed(0),
25
- );
26
- }
27
- }
28
-
29
3
  export function calculateMaxPriceLimit(isLong: boolean): bigint {
30
4
  // Determine if the amount is positive or negative and adjust the price accordingly
31
5
  if (isLong) {