@pear-protocol/utils 0.0.18 → 0.0.19
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/basket/basket.types.d.ts +0 -4
- package/dist/basket/compute.d.ts +1 -2
- package/dist/index.js +1 -12
- package/package.json +2 -2
package/dist/basket/compute.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InstrumentId } from '@pear-protocol/types';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BasketLeg } from './basket.types';
|
|
4
4
|
type PriceMap = Record<InstrumentId, string>;
|
|
5
5
|
/**
|
|
6
6
|
* Synthetic basket price:
|
|
@@ -12,5 +12,4 @@ type PriceMap = Record<InstrumentId, string>;
|
|
|
12
12
|
* exp( Σ(sign · weight · ln(price)) )
|
|
13
13
|
*/
|
|
14
14
|
export declare function computeBasketWeightedRatioV1(basket: BasketLeg[], priceMap: PriceMap): BigNumber | null;
|
|
15
|
-
export declare function computeBasketIndexV1(basket: BasketIndexLeg[], priceMap: PriceMap): BigNumber | null;
|
|
16
15
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -134,17 +134,6 @@ function computeBasketWeightedRatioV1(basket, priceMap) {
|
|
|
134
134
|
}
|
|
135
135
|
return exponentiate(logSum);
|
|
136
136
|
}
|
|
137
|
-
function computeBasketIndexV1(basket, priceMap) {
|
|
138
|
-
let logSum = 0;
|
|
139
|
-
for (const leg of basket) {
|
|
140
|
-
const price = priceMap[leg.symbol];
|
|
141
|
-
if (!price) return null;
|
|
142
|
-
const priceNum = Number(price);
|
|
143
|
-
if (priceNum <= 0) return null;
|
|
144
|
-
logSum += leg.weight * Math.log(priceNum);
|
|
145
|
-
}
|
|
146
|
-
return exponentiate(logSum);
|
|
147
|
-
}
|
|
148
137
|
function contractsToBase(contracts, contractSize) {
|
|
149
138
|
return new BigNumber7(contracts).times(contractSize);
|
|
150
139
|
}
|
|
@@ -614,4 +603,4 @@ function validateQuantity(quantity, price, precision) {
|
|
|
614
603
|
return true;
|
|
615
604
|
}
|
|
616
605
|
|
|
617
|
-
export { baseToContracts, computeAssetEntryNotional, computeAssetGrossRealizedPnL, computeAssetRealizedPnLs, computeAssetUnrealizedPnL, computeAssetUnrealizedPnLs,
|
|
606
|
+
export { baseToContracts, computeAssetEntryNotional, computeAssetGrossRealizedPnL, computeAssetRealizedPnLs, computeAssetUnrealizedPnL, computeAssetUnrealizedPnLs, computeBasketWeightedRatioV1, computeEntryPriceForAsset, computeRealizedPositionState, computeSyncPayload, computeUnrealizedPositionState, contractsToBase, countDecimals, exponentiate, precisePrice, preciseQuantity, validateLeverage, validateQuantity };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Pear Protocol Utility functions",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@pear-protocol/types": "^0.0.
|
|
29
|
+
"@pear-protocol/types": "^0.0.19",
|
|
30
30
|
"bignumber.js": "9.3.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|