@reyaxyz/common 0.98.2 → 0.99.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.
|
@@ -9,8 +9,8 @@ var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
|
9
9
|
function calculatePriceLimitForTrade(orderPrice, amount) {
|
|
10
10
|
// Ensure orderPrice is BigInt
|
|
11
11
|
var orderPriceBigInt = (0, bignumber_js_1.default)(orderPrice);
|
|
12
|
-
// Calculate
|
|
13
|
-
var offset = orderPriceBigInt.div(
|
|
12
|
+
// Calculate 1% of the order price
|
|
13
|
+
var offset = orderPriceBigInt.div(100);
|
|
14
14
|
// Determine if the amount is positive or negative and adjust the price accordingly
|
|
15
15
|
if (amount > 0) {
|
|
16
16
|
// Trade is long, so add
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trade.js","sourceRoot":"/","sources":["transactions/trade.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqC;AAErC,iHAAiH;AACjH,SAAgB,2BAA2B,CACzC,UAAkB,EAClB,MAAc;IAEd,8BAA8B;IAC9B,IAAM,gBAAgB,GAAG,IAAA,sBAAS,EAAC,UAAU,CAAC,CAAC;IAE/C,
|
|
1
|
+
{"version":3,"file":"trade.js","sourceRoot":"/","sources":["transactions/trade.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqC;AAErC,iHAAiH;AACjH,SAAgB,2BAA2B,CACzC,UAAkB,EAClB,MAAc;IAEd,8BAA8B;IAC9B,IAAM,gBAAgB,GAAG,IAAA,sBAAS,EAAC,UAAU,CAAC,CAAC;IAE/C,kCAAkC;IAClC,IAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEzC,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;AArBD,kEAqBC","sourcesContent":["import BigNumber from 'bignumber.js';\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): bigint {\n // Ensure orderPrice is BigInt\n const orderPriceBigInt = BigNumber(orderPrice);\n\n // Calculate 1% of the order price\n const offset = orderPriceBigInt.div(100);\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "pnpm@8.3.1",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "b1b7a94c5e83b36b298a4c6a5f55be882a12345a"
|
|
46
46
|
}
|
|
@@ -8,8 +8,8 @@ export function calculatePriceLimitForTrade(
|
|
|
8
8
|
// Ensure orderPrice is BigInt
|
|
9
9
|
const orderPriceBigInt = BigNumber(orderPrice);
|
|
10
10
|
|
|
11
|
-
// Calculate
|
|
12
|
-
const offset = orderPriceBigInt.div(
|
|
11
|
+
// Calculate 1% of the order price
|
|
12
|
+
const offset = orderPriceBigInt.div(100);
|
|
13
13
|
|
|
14
14
|
// Determine if the amount is positive or negative and adjust the price accordingly
|
|
15
15
|
if (amount > 0) {
|