@yuants/vendor-coinex 0.2.4 → 0.2.6

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/product.js CHANGED
@@ -47,7 +47,6 @@ createSQLWriter(terminal, {
47
47
  tableName: 'product',
48
48
  data$: product$,
49
49
  writeInterval: 1000,
50
- keyFn: (x) => encodePath(x.datasource_id, x.product_id),
51
50
  conflictKeys: ['datasource_id', 'product_id'],
52
51
  });
53
52
  futuresProducts$.subscribe();
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAY,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE;IACjD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,EAAE,KAAK,EAAE,IAAK,EAAE,CAAC,EACxB,KAAK,CAAC,EAAE,KAAK,EAAE,KAAM,EAAE,CAAC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,CAAC,IAAI,CACL,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;IACX,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC,EACF,GAAG,CAAC;IACF,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF,CAAC,EACF,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAS,EAAE,CAAC,EAC5B,WAAW,CAAC,CAAC,CAAC,CACf,CAAC;AAEF,eAAe,CAAW,QAAQ,EAAE;IAClC,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,QAAQ;IACf,aAAa,EAAE,IAAI;IACnB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC;IACvD,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;CAC9C,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,CAAC;AAE7B,MAAM,6BAA6B,GAAG,gBAAgB,CAAC,IAAI;AACzD,EAAE;AACF,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,WAAW,CAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n keyFn: (x) => encodePath(x.datasource_id, x.product_id),\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,E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AC,EACtB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAS,EAAE,CAAC,EAC5B,WAAW,CAAC,CAAC,CAAC,CACf,CAAC;AAEF,eAAe,CAAW,QAAQ,EAAE;IAClC,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,QAAQ;IACf,aAAa,EAAE,IAAI;IACnB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;CAC9C,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,CAAC;AAE7B,MAAM,6BAA6B,GAAG,gBAAgB,CAAC,IAAI;AACzD,EAAE;AACF,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,WAAW,CAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
package/lib/product.js CHANGED
@@ -50,7 +50,6 @@ const futuresProducts$ = (0, rxjs_1.defer)(async () => {
50
50
  tableName: 'product',
51
51
  data$: product$,
52
52
  writeInterval: 1000,
53
- keyFn: (x) => (0, utils_1.encodePath)(x.datasource_id, x.product_id),
54
53
  conflictKeys: ['datasource_id', 'product_id'],
55
54
  });
56
55
  futuresProducts$.subscribe();
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":";;;AACA,qCAA8C;AAC9C,yCAAuD;AACvD,+BAAqG;AACrG,+BAA+B;AAC/B,yCAAsC;AAEtC,MAAM,QAAQ,GAAG,IAAI,cAAO,EAAY,CAAC;AAE5B,QAAA,kBAAkB,GAAG,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACjD,MAAM,GAAG,GAAG,MAAM,YAAM,CAAC,gBAAgB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,GAAG,CA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EAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n keyFn: (x) => encodePath(x.datasource_id, x.product_id),\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":";;;AACA,qCAA8C;AAC9C,yCAAuD;AACvD,+BAAqG;AACrG,+BAA+B;AAC/B,yCAAsC;AAEtC,MAAM,QAAQ,GAAG,IAAI,cAAO,EAAY,CAAC;AAE5B,QAAA,kBAAkB,GAAG,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACjD,MAAM,GAAG,GAAG,MAAM,YAAM,CAAC,gBAAgB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC,CAAC,CAAC,IAAI,CACL,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,IAAK,EAAE,CAAC,EACxB,IAAA,YAAK,EAAC,EAAE,KAAK,EAAE,KAAM,EAAE,CAAC,EACxB,IAAA,eAAQ,EAAC,CAAC,CAAC,EAAE,EAAE,CACb,IAAA,WAAI,EAAC,CAAC,CAAC,CAAC,IAAI,CACV,IAAA,UAAG,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAU,CAAC,EAClC,IAAA,cAAO,GAAE,EACT,IAAA,UAAG,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CACvB,CACF,EACD,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AAEF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AAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF,CAAC,EACF,IAAA,YAAK,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtB,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,QAAS,EAAE,CAAC,EAC5B,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AAEF,IAAA,qBAAe,EAAW,mBAAQ,EAAE;IAClC,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,QAAQ;IACf,aAAa,EAAE,IAAI;IACnB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;CAC9C,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,CAAC;AAE7B,MAAM,6BAA6B,GAAG,gBAAgB,CAAC,IAAI;AACzD,EAAE;AACF,IAAA,UAAG,EAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-coinex",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "main": "lib/index.js",
5
5
  "bin": "lib/cli.js",
6
6
  "module": "dist/index.js",
@@ -10,13 +10,13 @@
10
10
  "temp"
11
11
  ],
12
12
  "dependencies": {
13
- "@yuants/protocol": "0.39.0",
14
- "@yuants/transfer": "0.2.7",
15
- "@yuants/utils": "0.7.0",
16
- "@yuants/sql": "0.8.6",
17
- "@yuants/data-series": "0.3.19",
18
- "@yuants/data-product": "0.2.8",
19
- "@yuants/data-interest-rate": "0.1.16",
13
+ "@yuants/protocol": "0.39.1",
14
+ "@yuants/transfer": "0.2.9",
15
+ "@yuants/utils": "0.7.1",
16
+ "@yuants/sql": "0.9.0",
17
+ "@yuants/data-series": "0.3.21",
18
+ "@yuants/data-product": "0.2.10",
19
+ "@yuants/data-interest-rate": "0.1.18",
20
20
  "rxjs": "~7.5.6",
21
21
  "crypto-js": "^4.2.0"
22
22
  },
@@ -27,8 +27,8 @@
27
27
  "@rushstack/heft-node-rig": "~1.10.7",
28
28
  "@types/heft-jest": "1.0.3",
29
29
  "@types/node": "22",
30
- "@yuants/extension": "0.2.22",
31
- "@yuants/tool-kit": "0.1.10",
30
+ "@yuants/extension": "0.2.23",
31
+ "@yuants/tool-kit": "0.2.0",
32
32
  "typescript": "~4.7.4",
33
33
  "ts-node": "~10.9.2"
34
34
  },
package/temp/image-tag CHANGED
@@ -1 +1 @@
1
- sha-564683dc2e88cf6e2bf4f8d7a7b576446f36d67d
1
+ sha-ea1c9433a7dba8018b79db968fde5098f97c0a1a
@@ -1,29 +1,29 @@
1
1
  {
2
- "apps/vendor-coinex/CHANGELOG.json": "7c02e992ba0b4f7095923e3e9e44b2ae26c24b1c",
3
- "apps/vendor-coinex/CHANGELOG.md": "23f4f92db1c73fc61b64af977aedc36873e06e1f",
2
+ "apps/vendor-coinex/CHANGELOG.json": "a5e48943b72434106ff43a5174dcfc698d531101",
3
+ "apps/vendor-coinex/CHANGELOG.md": "242b004b4a1a3a29f6cc4973324abde975c59b12",
4
4
  "apps/vendor-coinex/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
5
5
  "apps/vendor-coinex/build/Dockerfile": "8337903e3366ea6c13f1396269c082b8cb5dd96b",
6
6
  "apps/vendor-coinex/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
7
7
  "apps/vendor-coinex/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
8
8
  "apps/vendor-coinex/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
9
9
  "apps/vendor-coinex/etc/vendor-coinex.api.md": "33941b70ac7469421ff8fb8c157181014a0ea655",
10
- "apps/vendor-coinex/package.json": "0388deb825b704cc583630eaf88661e16213a453",
10
+ "apps/vendor-coinex/package.json": "fb39f157493956449fa00de55943e28da59c2885",
11
11
  "apps/vendor-coinex/src/api.ts": "5dc2027855a6f71ff98f88ad2329abeef40593fb",
12
12
  "apps/vendor-coinex/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
13
13
  "apps/vendor-coinex/src/extension.ts": "0a560546d341acebb59b1703be89c19fc2111a8b",
14
14
  "apps/vendor-coinex/src/index.ts": "1839b7a344b0f693f8e835f048a0bf6a69f5ff60",
15
15
  "apps/vendor-coinex/src/interest_rate.ts": "e085bb282420c139fd541f7fa8fb9a676121382f",
16
- "apps/vendor-coinex/src/product.ts": "415c59cf5fa9f56fae7b75978eb6b5b35e21748f",
16
+ "apps/vendor-coinex/src/product.ts": "220942cd49f2ca1846edab7708dc089d443591b1",
17
17
  "apps/vendor-coinex/src/terminal.ts": "04776a178d253a2e53f9c84c802e80f67aa9179b",
18
18
  "apps/vendor-coinex/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
19
19
  "apps/vendor-coinex/.rush/temp/shrinkwrap-deps.json": "65091c107a6149901dadc3fa1a7717446ce94f99",
20
- "libraries/protocol/temp/package-deps.json": "492e8469f3a0796d0f1b2b984d9ebb385b3a595b",
21
- "libraries/transfer/temp/package-deps.json": "c4d372cacb6000b6622f3ee18ca8611a3b475843",
22
- "libraries/utils/temp/package-deps.json": "3f2b8cbf9b8fa80dae9060cc1523fa23c920e758",
23
- "libraries/sql/temp/package-deps.json": "d2ccbe4de3b2a9fd71594326b9a216e870516bcf",
24
- "libraries/data-series/temp/package-deps.json": "3e27d28e8b871d506f3e68ecab779c83d3043ac0",
25
- "libraries/data-product/temp/package-deps.json": "85413d3ce6872959f4247e21cc3b1261ad8a0f73",
26
- "libraries/data-interest-rate/temp/package-deps.json": "6c525df9ff1ff6e5a33cc1b629c937f21a0bbd26",
27
- "libraries/extension/temp/package-deps.json": "da6e09910c67e923c7293f2da8efb3c7d568fc2c",
28
- "tools/toolkit/temp/package-deps.json": "eb0447c467da3a90db0913ed01e42ec0de840234"
20
+ "libraries/protocol/temp/package-deps.json": "9dd08f362a18e682103da293f1644d0be511dccb",
21
+ "libraries/transfer/temp/package-deps.json": "c419b1c288471f5bee32fc5de0c0268387526156",
22
+ "libraries/utils/temp/package-deps.json": "a8bc223d16ba49e526dfa5dff4b12043b9d69797",
23
+ "libraries/sql/temp/package-deps.json": "d347d47dfab59676b5e403405cc51c4b67ba1587",
24
+ "libraries/data-series/temp/package-deps.json": "aaafbf4054f878174832d643c9cd53516a3a18d5",
25
+ "libraries/data-product/temp/package-deps.json": "132c4d7ae32e2ef9cac9ba6de58a464e53be5822",
26
+ "libraries/data-interest-rate/temp/package-deps.json": "0c9266aab90a84e5a58dfbc02bba086596bd485f",
27
+ "libraries/extension/temp/package-deps.json": "ab7027477e102e1ee21a68d54473d801d4430c98",
28
+ "tools/toolkit/temp/package-deps.json": "3bef053db16659f0cdaceea64c8a8580c0131633"
29
29
  }