@pear-protocol/utils
Advanced tools
+1
-1
@@ -5,3 +5,3 @@ export * from './asset/index'; | ||
| export * from './fills/index'; | ||
| export { countDecimals, exponentiate } from './math/index'; | ||
| export * from './math/index'; | ||
| export * from './position/index'; | ||
@@ -8,0 +8,0 @@ export * from './precise-price'; |
+14
-7
@@ -10,2 +10,6 @@ import BigNumber7, { BigNumber } from 'bignumber.js'; | ||
| } | ||
| function sign(value) { | ||
| if (value.isZero()) return 0; | ||
| return value.isPositive() ? 1 : -1; | ||
| } | ||
| function countDecimals(value) { | ||
@@ -15,2 +19,5 @@ const parts = value.split("."); | ||
| } | ||
| function compareValue(track, value, threshold) { | ||
| return track === "PEAK" ? value.isGreaterThanOrEqualTo(threshold) : value.isLessThan(threshold); | ||
| } | ||
@@ -134,4 +141,4 @@ // src/fills/compute.ts | ||
| if (priceNum <= 0) return null; | ||
| const sign = leg.side === "BUY" ? 1 : -1; | ||
| logSum += sign * leg.weight * Math.log(priceNum); | ||
| const sign2 = leg.side === "BUY" ? 1 : -1; | ||
| logSum += sign2 * leg.weight * Math.log(priceNum); | ||
| } | ||
@@ -477,4 +484,4 @@ return exponentiate(logSum); | ||
| const quantity = new BigNumber(fill.quantity); | ||
| const sign = fill.side === "BUY" ? 1 : -1; | ||
| const signedQuantity = quantity.multipliedBy(sign); | ||
| const sign2 = fill.side === "BUY" ? 1 : -1; | ||
| const signedQuantity = quantity.multipliedBy(sign2); | ||
| netDelta = netDelta.plus(signedQuantity); | ||
@@ -496,4 +503,4 @@ } | ||
| } | ||
| const sign = fill.side === "BUY" ? 1 : -1; | ||
| const quantity = new BigNumber(fill.quantity).multipliedBy(sign); | ||
| const sign2 = fill.side === "BUY" ? 1 : -1; | ||
| const quantity = new BigNumber(fill.quantity).multipliedBy(sign2); | ||
| walkDelta = walkDelta.minus(quantity); | ||
@@ -611,2 +618,2 @@ } | ||
| export { baseToContracts, computeAssetEntryNotional, computeAssetGrossRealizedPnL, computeAssetRealizedPnLs, computeAssetUnrealizedPnL, computeAssetUnrealizedPnLs, computeBasketWeightedRatioV1, computeEntryPriceForAsset, computeRealizedPositionState, computeSyncPayload, computeUnrealizedPositionState, contractsToBase, countDecimals, exponentiate, precisePrice, preciseQuantity, validateLeverage, validateQuantity }; | ||
| export { BIPS, ZERO, baseToContracts, compareValue, computeAssetEntryNotional, computeAssetGrossRealizedPnL, computeAssetRealizedPnLs, computeAssetUnrealizedPnL, computeAssetUnrealizedPnLs, computeBasketWeightedRatioV1, computeEntryPriceForAsset, computeRealizedPositionState, computeSyncPayload, computeUnrealizedPositionState, contractsToBase, countDecimals, exponentiate, precisePrice, preciseQuantity, sign, validateLeverage, validateQuantity }; |
@@ -24,1 +24,2 @@ import BigNumber from 'bignumber.js'; | ||
| export declare function countDecimals(value: string): number; | ||
| export declare function compareValue(track: 'PEAK' | 'TROUGH', value: BigNumber, threshold: number): boolean; |
+2
-2
| { | ||
| "name": "@pear-protocol/utils", | ||
| "version": "0.0.22", | ||
| "version": "0.0.23", | ||
| "description": "Pear Protocol Utility functions", | ||
@@ -29,3 +29,3 @@ "private": false, | ||
| "dependencies": { | ||
| "@pear-protocol/types": "^0.1.0", | ||
| "@pear-protocol/types": "^1.0.0", | ||
| "bignumber.js": "9.3.1" | ||
@@ -32,0 +32,0 @@ }, |
36289
1.01%877
0.92%+ Added
- Removed
Updated