@pear-protocol/utils 0.2.0 → 0.3.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/dist/index.js +6 -3
- package/dist/sync/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -820,7 +820,10 @@ var WorkingBook = class _WorkingBook {
|
|
|
820
820
|
const book = new _WorkingBook(tradeAccountId);
|
|
821
821
|
for (const p of openPositions) {
|
|
822
822
|
const position = {
|
|
823
|
-
|
|
823
|
+
// Trust the position's own stored key — never recompute it from exposure.
|
|
824
|
+
// A partial fill on the original order leaves exposure short of the
|
|
825
|
+
// symbols the key was hashed from, so a recomputed key would never match.
|
|
826
|
+
positionKey: p.positionKey,
|
|
824
827
|
exposure: Exposure.fromRecord(p.exposure),
|
|
825
828
|
parts: [],
|
|
826
829
|
closed: false,
|
|
@@ -1106,7 +1109,7 @@ function assignSyntheticsToPositions(args) {
|
|
|
1106
1109
|
let target = positions.find((pos) => !pos.closed && pos.parts.some((part) => part.source.symbol === symbol));
|
|
1107
1110
|
if (!target) {
|
|
1108
1111
|
const existing = existingBySymbol.get(symbol);
|
|
1109
|
-
const positionKey = existing ?
|
|
1112
|
+
const positionKey = existing ? existing.positionKey : keyOf([symbol]);
|
|
1110
1113
|
target = positions.find((pos) => pos.positionKey === positionKey) ?? created.find((pos) => pos.positionKey === positionKey);
|
|
1111
1114
|
if (!target) {
|
|
1112
1115
|
target = existing ? (
|
|
@@ -1747,4 +1750,4 @@ function validateQuantity(quantity, price, precision) {
|
|
|
1747
1750
|
return true;
|
|
1748
1751
|
}
|
|
1749
1752
|
|
|
1750
|
-
export { BIPS, ZERO, abs, add, baseToContracts, compareValue, computeAssetEntryNotional, computeAssetGrossRealizedPnL, computeAssetRealizedPnLs, computeAssetUndeterminedSizes, computeAssetUnrealizedPnL, computeAssetUnrealizedPnLs, computeBasketWeightedRatioV1, computeEntryPriceForAsset, computePositionEntryPrices, computeRealizedPnlBySymbol, computeRealizedPnlFromFills, computeRealizedPositionState, computeSyncPayload, computeUnrealizedPositionState, computeUnrealizedPositionStateFromEntryPrices, configureProxy, contractsToBase, countDecimals, divide, exponentiate, generateDeterministicPositionKey, isEqualTo, isFiniteDecimal, isGreaterThan, isGreaterThanOrEqual, isLessThan, isLessThanOrEqual, isNegative, isPositive, isZero, min, multiply, negate, parse, precisePrice, preciseQuantity, proxyFetch, sideSign, sign, signed, signedBySide, subtract, toDecimalString, validateLeverage, validateQuantity };
|
|
1753
|
+
export { BIPS, ZERO, abs, add, baseToContracts, buildApplicables, compareValue, computeAssetEntryNotional, computeAssetGrossRealizedPnL, computeAssetRealizedPnLs, computeAssetUndeterminedSizes, computeAssetUnrealizedPnL, computeAssetUnrealizedPnLs, computeBasketWeightedRatioV1, computeEntryPriceForAsset, computePositionEntryPrices, computeRealizedPnlBySymbol, computeRealizedPnlFromFills, computeRealizedPositionState, computeSyncPayload, computeUnrealizedPositionState, computeUnrealizedPositionStateFromEntryPrices, configureProxy, contractsToBase, countDecimals, divide, exponentiate, generateDeterministicPositionKey, isEqualTo, isFiniteDecimal, isGreaterThan, isGreaterThanOrEqual, isLessThan, isLessThanOrEqual, isNegative, isPositive, isZero, min, multiply, negate, parse, precisePrice, preciseQuantity, proxyFetch, sideSign, sign, signed, signedBySide, subtract, toDecimalString, validateLeverage, validateQuantity };
|
package/dist/sync/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Pear Protocol Utility functions",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@noble/hashes": "^1.3.2",
|
|
30
|
-
"@pear-protocol/types": "^1.
|
|
30
|
+
"@pear-protocol/types": "^1.14.1",
|
|
31
31
|
"bignumber.js": "9.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|