@yuants/vendor-hyperliquid 0.1.0 → 0.1.2
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 +0 -2
- package/dist/index.js.map +1 -1
- package/dist/terminal.js +1 -5
- package/dist/terminal.js.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/lib/terminal.d.ts.map +1 -1
- package/lib/terminal.js +1 -5
- package/lib/terminal.js.map +1 -1
- package/package.json +2 -2
- package/temp/image-tag +1 -1
- package/temp/package-deps.json +6 -6
package/dist/index.js
CHANGED
|
@@ -31,7 +31,6 @@ const memoizeMap = (fn) => {
|
|
|
31
31
|
return {
|
|
32
32
|
account_id: `Hyperliquid/${client.public_key}`,
|
|
33
33
|
money: money,
|
|
34
|
-
currencies: [money],
|
|
35
34
|
positions: accountRes.assetPositions.map((position) => ({
|
|
36
35
|
position_id: `${position.position.coin}-USD`,
|
|
37
36
|
datasource_id: 'HYPERLIQUID',
|
|
@@ -45,7 +44,6 @@ const memoizeMap = (fn) => {
|
|
|
45
44
|
valuation: +position.position.positionValue,
|
|
46
45
|
margin: +position.position.marginUsed,
|
|
47
46
|
})),
|
|
48
|
-
orders: [],
|
|
49
47
|
updated_at: Date.now(),
|
|
50
48
|
};
|
|
51
49
|
}).pipe(
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS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AC,QAAQ,CAAC,GAAG,CAAC;oBACnF,eAAe,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa;oBACjD,SAAS,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa;oBAC3C,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU;iBACtC,CAAC,CACH;gBACD,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;aACvB,CAAC;QACJ,CAAC,CAAC,CAAC,IAAI;QACL,EAAE;QACF,GAAG,CAAC;YACF,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;gBACX,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,sBAAsB,EAAE,CAAC,CAAC,CAAC;YACnE,CAAC;SACF,CAAC,EACF,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtB,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACvB,WAAW,CAAC,CAAC,CAAC,CACf,CAAC;QACF,kBAAkB,CAAC,QAAQ,EAAE,eAAe,MAAM,CAAC,UAAU,EAAE,EAAE,gBAAgB,CAAC,CAAC;QACnF,gBAAgB,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,eAAe,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;KAC1G;IAED,0BAA0B;IAE1B,qBAAqB;IAErB,iBAAiB;AACnB,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import {\n addAccountMarket,\n IAccountInfo,\n IAccountMoney,\n IPosition,\n publishAccountInfo,\n} from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, repeat, retry, shareReplay, tap } from 'rxjs';\nimport { client } from './api';\nimport './order';\nimport './product';\nimport { terminal } from './terminal';\nimport './interest_rate';\n\nconst memoizeMap = <T extends (...params: any[]) => any>(fn: T): T => {\n const cache: Record<string, any> = {};\n return ((...params: any[]) => (cache[encodePath(params)] ??= fn(...params))) as T;\n};\n\n(async () => {\n // swap account info\n {\n const swapAccountInfo$ = defer(async (): Promise<IAccountInfo> => {\n const accountRes = await client.getUserPerpetualsAccountSummary({\n user: client.public_key!,\n });\n\n const profit = accountRes.assetPositions\n .map((pos) => +pos.position.unrealizedPnl)\n .reduce((a, b) => a + b, 0);\n\n const money: IAccountMoney = {\n currency: 'USDC',\n equity: +accountRes.crossMarginSummary.accountValue,\n profit: profit,\n free: +accountRes.withdrawable,\n used: +accountRes.crossMarginSummary.accountValue - +accountRes.withdrawable,\n balance: +accountRes.crossMarginSummary.accountValue - profit,\n };\n\n return {\n account_id: `Hyperliquid/${client.public_key}`,\n money: money,\n positions: accountRes.assetPositions.map(\n (position): IPosition => ({\n position_id: `${position.position.coin}-USD`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('PERPETUAL', `${position.position.coin}-USD`),\n direction: +position.position.szi > 0 ? 'LONG' : 'SHORT',\n volume: Math.abs(+position.position.szi),\n free_volume: Math.abs(+position.position.szi),\n position_price: +position.position.entryPx,\n closable_price: Math.abs(+position.position.positionValue / +position.position.szi),\n floating_profit: +position.position.unrealizedPnl,\n valuation: +position.position.positionValue,\n margin: +position.position.marginUsed,\n }),\n ),\n updated_at: Date.now(),\n };\n }).pipe(\n //\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'PerpetualAccountInfo', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 1000 }),\n shareReplay(1),\n );\n publishAccountInfo(terminal, `Hyperliquid/${client.public_key}`, swapAccountInfo$);\n addAccountMarket(terminal, { account_id: `Hyperliquid/${client.public_key}`, market_id: 'Hyperliquid' });\n }\n\n // TODO: spot account info\n\n // TODO: funding rate\n\n // TODO: transfer\n})();\n"]}
|
package/dist/terminal.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { Terminal } from '@yuants/protocol';
|
|
2
|
-
|
|
3
|
-
export const terminal = new Terminal(process.env.HOST_URL, {
|
|
4
|
-
terminal_id: process.env.TERMINAL_ID || `HyperLiquid/${UUID()}`,
|
|
5
|
-
name: 'HyperLiquid',
|
|
6
|
-
});
|
|
2
|
+
export const terminal = Terminal.fromNodeEnv();
|
|
7
3
|
//# sourceMappingURL=terminal.js.map
|
package/dist/terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\n\nexport const terminal = Terminal.fromNodeEnv();\n"]}
|
package/lib/index.js
CHANGED
|
@@ -33,7 +33,6 @@ const memoizeMap = (fn) => {
|
|
|
33
33
|
return {
|
|
34
34
|
account_id: `Hyperliquid/${api_1.client.public_key}`,
|
|
35
35
|
money: money,
|
|
36
|
-
currencies: [money],
|
|
37
36
|
positions: accountRes.assetPositions.map((position) => ({
|
|
38
37
|
position_id: `${position.position.coin}-USD`,
|
|
39
38
|
datasource_id: 'HYPERLIQUID',
|
|
@@ -47,7 +46,6 @@ const memoizeMap = (fn) => {
|
|
|
47
46
|
valuation: +position.position.positionValue,
|
|
48
47
|
margin: +position.position.marginUsed,
|
|
49
48
|
})),
|
|
50
|
-
orders: [],
|
|
51
49
|
updated_at: Date.now(),
|
|
52
50
|
};
|
|
53
51
|
}).pipe(
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uDAM8B;AAC9B,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G,EAAE;aACvB,CAAC;QACJ,CAAC,CAAC,CAAC,IAAI;QACL,EAAE;QACF,IAAA,UAAG,EAAC;YACF,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;gBACX,OAAO,CAAC,KAAK,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,sBAAsB,EAAE,CAAC,CAAC,CAAC;YACnE,CAAC;SACF,CAAC,EACF,IAAA,YAAK,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtB,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACvB,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QACF,IAAA,iCAAkB,EAAC,mBAAQ,EAAE,eAAe,YAAM,CAAC,UAAU,EAAE,EAAE,gBAAgB,CAAC,CAAC;QACnF,IAAA,+BAAgB,EAAC,mBAAQ,EAAE,EAAE,UAAU,EAAE,eAAe,YAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;KAC1G;IAED,0BAA0B;IAE1B,qBAAqB;IAErB,iBAAiB;AACnB,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import {\n addAccountMarket,\n IAccountInfo,\n IAccountMoney,\n IPosition,\n publishAccountInfo,\n} from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, repeat, retry, shareReplay, tap } from 'rxjs';\nimport { client } from './api';\nimport './order';\nimport './product';\nimport { terminal } from './terminal';\nimport './interest_rate';\n\nconst memoizeMap = <T extends (...params: any[]) => any>(fn: T): T => {\n const cache: Record<string, any> = {};\n return ((...params: any[]) => (cache[encodePath(params)] ??= fn(...params))) as T;\n};\n\n(async () => {\n // swap account info\n {\n const swapAccountInfo$ = defer(async (): Promise<IAccountInfo> => {\n const accountRes = await client.getUserPerpetualsAccountSummary({\n user: client.public_key!,\n });\n\n const profit = accountRes.assetPositions\n .map((pos) => +pos.position.unrealizedPnl)\n .reduce((a, b) => a + b, 0);\n\n const money: IAccountMoney = {\n currency: 'USDC',\n equity: +accountRes.crossMarginSummary.accountValue,\n profit: profit,\n free: +accountRes.withdrawable,\n used: +accountRes.crossMarginSummary.accountValue - +accountRes.withdrawable,\n balance: +accountRes.crossMarginSummary.accountValue - profit,\n };\n\n return {\n account_id: `Hyperliquid/${client.public_key}`,\n money: money,\n positions: accountRes.assetPositions.map(\n (position): IPosition => ({\n position_id: `${position.position.coin}-USD`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('PERPETUAL', `${position.position.coin}-USD`),\n direction: +position.position.szi > 0 ? 'LONG' : 'SHORT',\n volume: Math.abs(+position.position.szi),\n free_volume: Math.abs(+position.position.szi),\n position_price: +position.position.entryPx,\n closable_price: Math.abs(+position.position.positionValue / +position.position.szi),\n floating_profit: +position.position.unrealizedPnl,\n valuation: +position.position.positionValue,\n margin: +position.position.marginUsed,\n }),\n ),\n updated_at: Date.now(),\n };\n }).pipe(\n //\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'PerpetualAccountInfo', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 1000 }),\n shareReplay(1),\n );\n publishAccountInfo(terminal, `Hyperliquid/${client.public_key}`, swapAccountInfo$);\n addAccountMarket(terminal, { account_id: `Hyperliquid/${client.public_key}`, market_id: 'Hyperliquid' });\n }\n\n // TODO: spot account info\n\n // TODO: funding rate\n\n // TODO: transfer\n})();\n"]}
|
package/lib/terminal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,eAAO,MAAM,QAAQ,UAAyB,CAAC"}
|
package/lib/terminal.js
CHANGED
|
@@ -2,9 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.terminal = void 0;
|
|
4
4
|
const protocol_1 = require("@yuants/protocol");
|
|
5
|
-
|
|
6
|
-
exports.terminal = new protocol_1.Terminal(process.env.HOST_URL, {
|
|
7
|
-
terminal_id: process.env.TERMINAL_ID || `HyperLiquid/${(0, utils_1.UUID)()}`,
|
|
8
|
-
name: 'HyperLiquid',
|
|
9
|
-
});
|
|
5
|
+
exports.terminal = protocol_1.Terminal.fromNodeEnv();
|
|
10
6
|
//# sourceMappingURL=terminal.js.map
|
package/lib/terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAE/B,QAAA,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\n\nexport const terminal = Terminal.fromNodeEnv();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-hyperliquid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"bin": "lib/cli.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@yuants/protocol": "0.37.2",
|
|
12
12
|
"@yuants/transfer": "0.2.4",
|
|
13
|
-
"@yuants/data-account": "0.3.
|
|
13
|
+
"@yuants/data-account": "0.3.4",
|
|
14
14
|
"@yuants/utils": "0.5.0",
|
|
15
15
|
"@yuants/sql": "0.8.3",
|
|
16
16
|
"@yuants/data-product": "0.2.5",
|
package/temp/image-tag
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
sha-
|
|
1
|
+
sha-0c1bfa2b21f6e3fa5f4d11f2cb1ffaacb86b07e8
|
package/temp/package-deps.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
"apps/vendor-hyperliquid/CHANGELOG.json": "
|
|
3
|
-
"apps/vendor-hyperliquid/CHANGELOG.md": "
|
|
2
|
+
"apps/vendor-hyperliquid/CHANGELOG.json": "2592beaea870323eaa18a4e103cfb4f46f043f59",
|
|
3
|
+
"apps/vendor-hyperliquid/CHANGELOG.md": "218fc9ec13e29307a97f342e19fc3530bc795cff",
|
|
4
4
|
"apps/vendor-hyperliquid/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
|
|
5
5
|
"apps/vendor-hyperliquid/build/Dockerfile": "1c2ae19b2c8549403281594a463aaae67d70400c",
|
|
6
6
|
"apps/vendor-hyperliquid/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
7
7
|
"apps/vendor-hyperliquid/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
8
8
|
"apps/vendor-hyperliquid/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
9
9
|
"apps/vendor-hyperliquid/etc/vendor-hyperliquid.api.md": "66675bd88afa1fe945f0d4023984c1c9c3e60a34",
|
|
10
|
-
"apps/vendor-hyperliquid/package.json": "
|
|
10
|
+
"apps/vendor-hyperliquid/package.json": "735240ef4a7363f80e597f2319a315cd6f68b3e3",
|
|
11
11
|
"apps/vendor-hyperliquid/src/api.ts": "f30431f81789561acc3b8861a71b20053aeb0b0a",
|
|
12
12
|
"apps/vendor-hyperliquid/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
|
|
13
13
|
"apps/vendor-hyperliquid/src/extension.ts": "451dc84e9d62d0e87aec1e04a2a8375aaef873a3",
|
|
14
|
-
"apps/vendor-hyperliquid/src/index.ts": "
|
|
14
|
+
"apps/vendor-hyperliquid/src/index.ts": "0b84c433e1cb0c6b718e54f88c213c9d1b632691",
|
|
15
15
|
"apps/vendor-hyperliquid/src/interest_rate.ts": "5b46f8a4904734d9801e3ddd1146813918e36835",
|
|
16
16
|
"apps/vendor-hyperliquid/src/order.ts": "26bbe7b5e52a7b7fbff4ea7bb8944b7c7b42d664",
|
|
17
17
|
"apps/vendor-hyperliquid/src/product.ts": "73a920896d1c825885d93c244de7d48ab93bb902",
|
|
18
18
|
"apps/vendor-hyperliquid/src/sign.ts": "94f4e5604a01d197d164b42415b17789ab2b6889",
|
|
19
|
-
"apps/vendor-hyperliquid/src/terminal.ts": "
|
|
19
|
+
"apps/vendor-hyperliquid/src/terminal.ts": "04776a178d253a2e53f9c84c802e80f67aa9179b",
|
|
20
20
|
"apps/vendor-hyperliquid/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
|
|
21
21
|
"apps/vendor-hyperliquid/.rush/temp/shrinkwrap-deps.json": "926c9074c4884ebaf0104ca91ed05ffd99d007cb",
|
|
22
22
|
"libraries/protocol/temp/package-deps.json": "d326f24867d9ae3fef16ff84ba537eabb7c8adf0",
|
|
23
23
|
"libraries/transfer/temp/package-deps.json": "cb2786055e5e79cd7d9d0f5787e300ca1c0bf002",
|
|
24
|
-
"libraries/data-account/temp/package-deps.json": "
|
|
24
|
+
"libraries/data-account/temp/package-deps.json": "0e5bd33f40288d3bc2a3b32cf51188a346a8dd34",
|
|
25
25
|
"libraries/utils/temp/package-deps.json": "c747617da1c0a40843603c62a7477da641ff0aef",
|
|
26
26
|
"libraries/sql/temp/package-deps.json": "1cb2248873d01ed732e8473f7b242a41f987fdd7",
|
|
27
27
|
"libraries/data-product/temp/package-deps.json": "634e636d948295079b02dbeffb84f6d52872fda8",
|