@yuants/vendor-aster 0.7.4 → 0.7.5
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/services/accounts/perp.js +1 -8
- package/dist/services/accounts/perp.js.map +1 -1
- package/dist/services/accounts/spot.js +6 -24
- package/dist/services/accounts/spot.js.map +1 -1
- package/lib/services/accounts/perp.d.ts.map +1 -1
- package/lib/services/accounts/perp.js +1 -8
- package/lib/services/accounts/perp.js.map +1 -1
- package/lib/services/accounts/spot.d.ts.map +1 -1
- package/lib/services/accounts/spot.js +6 -24
- package/lib/services/accounts/spot.js.map +1 -1
- package/package.json +2 -2
- package/temp/package-deps.json +6 -6
|
@@ -18,13 +18,6 @@ export const getPerpAccountInfo = async (credential) => {
|
|
|
18
18
|
floating_profit: +p.unrealizedProfit,
|
|
19
19
|
valuation: Math.abs(+p.notional),
|
|
20
20
|
}));
|
|
21
|
-
return
|
|
22
|
-
money: {
|
|
23
|
-
currency: 'USD',
|
|
24
|
-
equity,
|
|
25
|
-
free,
|
|
26
|
-
},
|
|
27
|
-
positions,
|
|
28
|
-
};
|
|
21
|
+
return positions;
|
|
29
22
|
};
|
|
30
23
|
//# sourceMappingURL=perp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perp.js","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAe,MAAM,uBAAuB,CAAC;AAEtE,MAAM,CAAC,MAAM,kBAAkB,GAAgD,KAAK,EAAE,UAAU,EAAE,EAAE;IAClG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAElE,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC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AAC,CAAC,CAAC,QAAQ,CAAC;KACjC,CAAC,CACH,CAAC;IACJ,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { IActionHandlerOfGetAccountInfo, IPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getFApiV4Account, ICredential } from '../../api/private-api';\n\nexport const getPerpAccountInfo: IActionHandlerOfGetAccountInfo<ICredential> = async (credential) => {\n const [a] = await Promise.all([getFApiV4Account(credential, {})]);\n\n const equity = +a.totalWalletBalance + +a.totalUnrealizedProfit;\n const free = +a.availableBalance;\n\n const positions = a.positions\n .filter((p) => +p.positionAmt !== 0)\n .map(\n (p): IPosition => ({\n position_id: p.symbol,\n product_id: encodePath('PERPETUAL', p.symbol),\n datasource_id: 'ASTER',\n direction: p.positionSide === 'BOTH' ? (+p.positionAmt > 0 ? 'LONG' : 'SHORT') : p.positionSide,\n volume: Math.abs(+p.positionAmt),\n free_volume: Math.abs(+p.positionAmt),\n position_price: +p.entryPrice,\n closable_price: Math.abs(+p.notional / +p.positionAmt),\n floating_profit: +p.unrealizedProfit,\n valuation: Math.abs(+p.notional),\n }),\n );\n return positions;\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { makeSpotPosition } from '@yuants/data-account';
|
|
1
2
|
import { getApiV1Account, getApiV1TickerPrice } from '../../api/private-api';
|
|
2
3
|
export const getSpotAccountInfo = async (credential, account_id) => {
|
|
3
4
|
const [x, prices] = await Promise.all([
|
|
@@ -7,34 +8,15 @@ export const getSpotAccountInfo = async (credential, account_id) => {
|
|
|
7
8
|
const positions = x.balances.map((b) => {
|
|
8
9
|
var _a, _b;
|
|
9
10
|
const thePrice = b.asset === 'USDT' ? 1 : (_b = (_a = prices.find((p) => p.symbol === b.asset + 'USDT')) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
10
|
-
|
|
11
|
-
const position_price = +thePrice;
|
|
12
|
-
const closable_price = +thePrice;
|
|
13
|
-
const valuation = volume * closable_price;
|
|
14
|
-
const floating_profit = 0;
|
|
15
|
-
return {
|
|
11
|
+
return makeSpotPosition({
|
|
16
12
|
position_id: b.asset,
|
|
17
13
|
datasource_id: 'ASTER',
|
|
18
14
|
product_id: b.asset,
|
|
19
|
-
|
|
20
|
-
volume,
|
|
15
|
+
volume: +b.free + +b.locked,
|
|
21
16
|
free_volume: +b.free,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
floating_profit,
|
|
25
|
-
valuation,
|
|
26
|
-
};
|
|
17
|
+
closable_price: +thePrice,
|
|
18
|
+
});
|
|
27
19
|
});
|
|
28
|
-
|
|
29
|
-
const equity = positions.reduce((a, b) => a + b.valuation, 0);
|
|
30
|
-
const free = usdtAsset ? +usdtAsset.free : 0;
|
|
31
|
-
return {
|
|
32
|
-
money: {
|
|
33
|
-
currency: 'USDT',
|
|
34
|
-
equity,
|
|
35
|
-
free,
|
|
36
|
-
},
|
|
37
|
-
positions,
|
|
38
|
-
};
|
|
20
|
+
return positions;
|
|
39
21
|
};
|
|
40
22
|
//# sourceMappingURL=spot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAe,MAAM,uBAAuB,CAAC;AAE1F,MAAM,CAAC,MAAM,kBAAkB,GAAgD,KAAK,EAClF,UAAU,EACV,UAAU,EACV,EAAE;IACF,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpC,eAAe,CAAC,UAAU,EAAE,EAAE,CAAC;QAC/B,mBAAmB,CAAC,UAAU,EAAE,EAAE,CAAC;KACpC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAa,EAAE;;QAChD,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,MAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,0CAAE,KAAK,mCAAI,CAAC,CAAC;QAExG,OAAO,gBAAgB,CAAC;YACtB,WAAW,EAAE,CAAC,CAAC,KAAK;YACpB,aAAa,EAAE,OAAO;YACtB,UAAU,EAAE,CAAC,CAAC,KAAK;YACnB,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM;YAC3B,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI;YACpB,cAAc,EAAE,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { IActionHandlerOfGetAccountInfo, IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { getApiV1Account, getApiV1TickerPrice, ICredential } from '../../api/private-api';\n\nexport const getSpotAccountInfo: IActionHandlerOfGetAccountInfo<ICredential> = async (\n credential,\n account_id,\n) => {\n const [x, prices] = await Promise.all([\n getApiV1Account(credential, {}),\n getApiV1TickerPrice(credential, {}),\n ]);\n\n const positions = x.balances.map((b): IPosition => {\n const thePrice = b.asset === 'USDT' ? 1 : prices.find((p) => p.symbol === b.asset + 'USDT')?.price ?? 0;\n\n return makeSpotPosition({\n position_id: b.asset,\n datasource_id: 'ASTER',\n product_id: b.asset,\n volume: +b.free + +b.locked,\n free_volume: +b.free,\n closable_price: +thePrice,\n });\n });\n\n return positions;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perp.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAa,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEtE,eAAO,MAAM,kBAAkB,EAAE,8BAA8B,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"perp.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAa,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEtE,eAAO,MAAM,kBAAkB,EAAE,8BAA8B,CAAC,WAAW,CAuB1E,CAAC"}
|
|
@@ -21,14 +21,7 @@ const getPerpAccountInfo = async (credential) => {
|
|
|
21
21
|
floating_profit: +p.unrealizedProfit,
|
|
22
22
|
valuation: Math.abs(+p.notional),
|
|
23
23
|
}));
|
|
24
|
-
return
|
|
25
|
-
money: {
|
|
26
|
-
currency: 'USD',
|
|
27
|
-
equity,
|
|
28
|
-
free,
|
|
29
|
-
},
|
|
30
|
-
positions,
|
|
31
|
-
};
|
|
24
|
+
return positions;
|
|
32
25
|
};
|
|
33
26
|
exports.getPerpAccountInfo = getPerpAccountInfo;
|
|
34
27
|
//# sourceMappingURL=perp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perp.js","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":";;;AACA,yCAA2C;AAC3C,uDAAsE;AAE/D,MAAM,kBAAkB,GAAgD,KAAK,EAAE,UAAU,EAAE,EAAE;IAClG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,8BAAgB,EAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAElE,MAAM,MAAM,GAAG,C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AAC;KACjC,CAAC,CACH,CAAC;IACJ,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAvBW,QAAA,kBAAkB,sBAuB7B","sourcesContent":["import { IActionHandlerOfGetAccountInfo, IPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getFApiV4Account, ICredential } from '../../api/private-api';\n\nexport const getPerpAccountInfo: IActionHandlerOfGetAccountInfo<ICredential> = async (credential) => {\n const [a] = await Promise.all([getFApiV4Account(credential, {})]);\n\n const equity = +a.totalWalletBalance + +a.totalUnrealizedProfit;\n const free = +a.availableBalance;\n\n const positions = a.positions\n .filter((p) => +p.positionAmt !== 0)\n .map(\n (p): IPosition => ({\n position_id: p.symbol,\n product_id: encodePath('PERPETUAL', p.symbol),\n datasource_id: 'ASTER',\n direction: p.positionSide === 'BOTH' ? (+p.positionAmt > 0 ? 'LONG' : 'SHORT') : p.positionSide,\n volume: Math.abs(+p.positionAmt),\n free_volume: Math.abs(+p.positionAmt),\n position_price: +p.entryPrice,\n closable_price: Math.abs(+p.notional / +p.positionAmt),\n floating_profit: +p.unrealizedProfit,\n valuation: Math.abs(+p.notional),\n }),\n );\n return positions;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spot.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,
|
|
1
|
+
{"version":3,"file":"spot.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAA+B,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAwC,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE1F,eAAO,MAAM,kBAAkB,EAAE,8BAA8B,CAAC,WAAW,CAuB1E,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSpotAccountInfo = void 0;
|
|
4
|
+
const data_account_1 = require("@yuants/data-account");
|
|
4
5
|
const private_api_1 = require("../../api/private-api");
|
|
5
6
|
const getSpotAccountInfo = async (credential, account_id) => {
|
|
6
7
|
const [x, prices] = await Promise.all([
|
|
@@ -10,35 +11,16 @@ const getSpotAccountInfo = async (credential, account_id) => {
|
|
|
10
11
|
const positions = x.balances.map((b) => {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
const thePrice = b.asset === 'USDT' ? 1 : (_b = (_a = prices.find((p) => p.symbol === b.asset + 'USDT')) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0;
|
|
13
|
-
|
|
14
|
-
const position_price = +thePrice;
|
|
15
|
-
const closable_price = +thePrice;
|
|
16
|
-
const valuation = volume * closable_price;
|
|
17
|
-
const floating_profit = 0;
|
|
18
|
-
return {
|
|
14
|
+
return (0, data_account_1.makeSpotPosition)({
|
|
19
15
|
position_id: b.asset,
|
|
20
16
|
datasource_id: 'ASTER',
|
|
21
17
|
product_id: b.asset,
|
|
22
|
-
|
|
23
|
-
volume,
|
|
18
|
+
volume: +b.free + +b.locked,
|
|
24
19
|
free_volume: +b.free,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
floating_profit,
|
|
28
|
-
valuation,
|
|
29
|
-
};
|
|
20
|
+
closable_price: +thePrice,
|
|
21
|
+
});
|
|
30
22
|
});
|
|
31
|
-
|
|
32
|
-
const equity = positions.reduce((a, b) => a + b.valuation, 0);
|
|
33
|
-
const free = usdtAsset ? +usdtAsset.free : 0;
|
|
34
|
-
return {
|
|
35
|
-
money: {
|
|
36
|
-
currency: 'USDT',
|
|
37
|
-
equity,
|
|
38
|
-
free,
|
|
39
|
-
},
|
|
40
|
-
positions,
|
|
41
|
-
};
|
|
23
|
+
return positions;
|
|
42
24
|
};
|
|
43
25
|
exports.getSpotAccountInfo = getSpotAccountInfo;
|
|
44
26
|
//# sourceMappingURL=spot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":";;;AAAA,uDAAmG;AACnG,uDAA0F;AAEnF,MAAM,kBAAkB,GAAgD,KAAK,EAClF,UAAU,EACV,UAAU,EACV,EAAE;IACF,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpC,IAAA,6BAAe,EAAC,UAAU,EAAE,EAAE,CAAC;QAC/B,IAAA,iCAAmB,EAAC,UAAU,EAAE,EAAE,CAAC;KACpC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAa,EAAE;;QAChD,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,MAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,0CAAE,KAAK,mCAAI,CAAC,CAAC;QAExG,OAAO,IAAA,+BAAgB,EAAC;YACtB,WAAW,EAAE,CAAC,CAAC,KAAK;YACpB,aAAa,EAAE,OAAO;YACtB,UAAU,EAAE,CAAC,CAAC,KAAK;YACnB,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM;YAC3B,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI;YACpB,cAAc,EAAE,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAvBW,QAAA,kBAAkB,sBAuB7B","sourcesContent":["import { IActionHandlerOfGetAccountInfo, IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { getApiV1Account, getApiV1TickerPrice, ICredential } from '../../api/private-api';\n\nexport const getSpotAccountInfo: IActionHandlerOfGetAccountInfo<ICredential> = async (\n credential,\n account_id,\n) => {\n const [x, prices] = await Promise.all([\n getApiV1Account(credential, {}),\n getApiV1TickerPrice(credential, {}),\n ]);\n\n const positions = x.balances.map((b): IPosition => {\n const thePrice = b.asset === 'USDT' ? 1 : prices.find((p) => p.symbol === b.asset + 'USDT')?.price ?? 0;\n\n return makeSpotPosition({\n position_id: b.asset,\n datasource_id: 'ASTER',\n product_id: b.asset,\n volume: +b.free + +b.locked,\n free_volume: +b.free,\n closable_price: +thePrice,\n });\n });\n\n return positions;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-aster",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@yuants/protocol": "0.52.0",
|
|
12
12
|
"@yuants/cache": "0.3.0",
|
|
13
|
-
"@yuants/data-account": "0.
|
|
13
|
+
"@yuants/data-account": "0.8.0",
|
|
14
14
|
"@yuants/utils": "0.11.0",
|
|
15
15
|
"@yuants/data-series": "0.3.47",
|
|
16
16
|
"@yuants/sql": "0.9.26",
|
package/temp/package-deps.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apps/vendor-aster/AGENTS.md": "dcd006d19a5c3b73081525d7c0afea68cd6d058b",
|
|
3
|
-
"apps/vendor-aster/CHANGELOG.json": "
|
|
4
|
-
"apps/vendor-aster/CHANGELOG.md": "
|
|
3
|
+
"apps/vendor-aster/CHANGELOG.json": "d7ad5f5495d20652b40515fba8a96c986e9ae669",
|
|
4
|
+
"apps/vendor-aster/CHANGELOG.md": "feed6c577bddf600e744e44694f219ffd8a1669d",
|
|
5
5
|
"apps/vendor-aster/SESSION_NOTES.md": "f54c13cf4182d8a5e720f6db5d3acc323655ea49",
|
|
6
6
|
"apps/vendor-aster/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
7
7
|
"apps/vendor-aster/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
8
8
|
"apps/vendor-aster/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
9
|
-
"apps/vendor-aster/package.json": "
|
|
9
|
+
"apps/vendor-aster/package.json": "6868ff961b9ffb8a0a3cebd1ea3551d10c2d094c",
|
|
10
10
|
"apps/vendor-aster/src/api/private-api.ts": "ad888086c0c7793b8cdf3f095c1f790368d4e966",
|
|
11
11
|
"apps/vendor-aster/src/api/public-api.ts": "bfc642fff0ae31319c23e198f365a4a3372d4b10",
|
|
12
12
|
"apps/vendor-aster/src/index.ts": "603b5c4e487389ce5c815ed5122a408abde43e17",
|
|
13
13
|
"apps/vendor-aster/src/services/account-actions-with-credential.ts": "2d78127a969acaa4b0b39b8a93fcd3f0b76fd158",
|
|
14
|
-
"apps/vendor-aster/src/services/accounts/perp.ts": "
|
|
15
|
-
"apps/vendor-aster/src/services/accounts/spot.ts": "
|
|
14
|
+
"apps/vendor-aster/src/services/accounts/perp.ts": "790004ac274d4a56fc18026e7dd99e8e54e9803d",
|
|
15
|
+
"apps/vendor-aster/src/services/accounts/spot.ts": "9461d9f68c48d11a249aa01d6be49ef2cdfbfacf",
|
|
16
16
|
"apps/vendor-aster/src/services/legacy.ts": "72d322567eb377e490c9fe26e6247f11de40154b",
|
|
17
17
|
"apps/vendor-aster/src/services/markets/interest_rate.ts": "15befd821b9cefd892210d26228f0c84a124a28e",
|
|
18
18
|
"apps/vendor-aster/src/services/markets/product.ts": "ddab6fc348a0fff17ef717683cbc2caf48c38513",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"apps/vendor-aster/.rush/temp/shrinkwrap-deps.json": "8909c2a52371c1bd644b09b7ccbb4bbaf29d53dd",
|
|
27
27
|
"libraries/protocol/temp/package-deps.json": "52d2a645608a17915da897e48a70b415312a94fb",
|
|
28
28
|
"libraries/cache/temp/package-deps.json": "49789a92426969daa31f0c956bb56bd783929765",
|
|
29
|
-
"libraries/data-account/temp/package-deps.json": "
|
|
29
|
+
"libraries/data-account/temp/package-deps.json": "459a552a5ff4304fff00dfd369bb0746bd33cf5f",
|
|
30
30
|
"libraries/utils/temp/package-deps.json": "c58f1ca8f498315d9a0219ca8c498299a41d297b",
|
|
31
31
|
"libraries/data-series/temp/package-deps.json": "87e55f6234501a066d38534b8f563f62354483af",
|
|
32
32
|
"libraries/sql/temp/package-deps.json": "f718628b404248148aaa692928681b1087ccc7ba",
|