@lifi/perps-sdk-provider-hyperliquid 0.0.0-preview-20acc5e → 0.0.0-preview-cbbc415
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/cjs/services/getActivity.d.ts.map +1 -1
- package/dist/cjs/services/getActivity.js +1 -8
- package/dist/cjs/services/getActivity.js.map +1 -1
- package/dist/cjs/types/ledger.d.ts +1 -24
- package/dist/cjs/types/ledger.d.ts.map +1 -1
- package/dist/cjs/types/ledger.js +1 -8
- package/dist/cjs/types/ledger.js.map +1 -1
- package/dist/cjs/utils/mapActivity.d.ts.map +1 -1
- package/dist/cjs/utils/mapActivity.js +39 -47
- package/dist/cjs/utils/mapActivity.js.map +1 -1
- package/dist/esm/services/getActivity.d.ts.map +1 -1
- package/dist/esm/services/getActivity.js +1 -10
- package/dist/esm/services/getActivity.js.map +1 -1
- package/dist/esm/types/ledger.d.ts +1 -61
- package/dist/esm/types/ledger.d.ts.map +1 -1
- package/dist/esm/types/ledger.js +0 -22
- package/dist/esm/types/ledger.js.map +1 -1
- package/dist/esm/utils/mapActivity.d.ts +2 -2
- package/dist/esm/utils/mapActivity.d.ts.map +1 -1
- package/dist/esm/utils/mapActivity.js +45 -56
- package/dist/esm/utils/mapActivity.js.map +1 -1
- package/dist/types/services/getActivity.d.ts.map +1 -1
- package/dist/types/types/ledger.d.ts +1 -61
- package/dist/types/types/ledger.d.ts.map +1 -1
- package/dist/types/utils/mapActivity.d.ts +2 -2
- package/dist/types/utils/mapActivity.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/services/getActivity.ts +1 -13
- package/src/types/ledger.ts +0 -80
- package/src/utils/mapActivity.ts +52 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getActivity.d.ts","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC3E,OAAO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-6,11 +6,6 @@ const perps_types_1 = require("@lifi/perps-types");
|
|
|
6
6
|
const constants_js_1 = require("../constants.js");
|
|
7
7
|
const index_js_1 = require("../utils/index.js");
|
|
8
8
|
const infoClient_js_1 = require("../utils/infoClient.js");
|
|
9
|
-
const MARKET_BEARING_TYPES = new Set([
|
|
10
|
-
perps_types_1.ActivityType.FUNDING,
|
|
11
|
-
perps_types_1.ActivityType.LIQUIDATION,
|
|
12
|
-
]);
|
|
13
|
-
const needsMarkets = (typeFilter) => !typeFilter || typeFilter.some((t) => MARKET_BEARING_TYPES.has(t));
|
|
14
9
|
const fetchActivityData = async (apiUrl, typeFilter, timeParams, resolveMarket, options) => {
|
|
15
10
|
const needLedger = !typeFilter || typeFilter.some((t) => t !== perps_types_1.ActivityType.FUNDING);
|
|
16
11
|
const needFunding = !typeFilter || typeFilter.includes(perps_types_1.ActivityType.FUNDING);
|
|
@@ -35,9 +30,7 @@ const fetchActivityData = async (apiUrl, typeFilter, timeParams, resolveMarket,
|
|
|
35
30
|
};
|
|
36
31
|
const getActivity = async ({ client, apiUrl }, params, options) => {
|
|
37
32
|
const registry = (0, perps_sdk_1.getMarketRegistry)(client, constants_js_1.PROVIDER_KEY);
|
|
38
|
-
|
|
39
|
-
await registry.sync();
|
|
40
|
-
}
|
|
33
|
+
await registry.sync();
|
|
41
34
|
const infoOpts = (0, infoClient_js_1.hlInfoOptions)(client, options);
|
|
42
35
|
const limit = Math.min(params.limit ?? constants_js_1.DEFAULT_HISTORY_LIMIT, constants_js_1.MAX_HISTORY_LIMIT);
|
|
43
36
|
const startTime = params.startTime ?? Date.now() - constants_js_1.NINETY_DAYS_MS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getActivity.js","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":";;;AAAA,+CAA2E;AAM3E,mDAAgD;AAEhD,kDAKwB;AAMxB,gDAAsE;AACtE,0DAI+B;AAqB/B,MAAM,
|
|
1
|
+
{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WAAW,eA2DvB"}
|
|
@@ -24,36 +24,13 @@ export type HlSendAssetDelta = {
|
|
|
24
24
|
nonce: number;
|
|
25
25
|
feeToken: string;
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
28
|
-
type: 'deposit';
|
|
29
|
-
usdc: string;
|
|
30
|
-
};
|
|
31
|
-
export type HlWithdrawDelta = {
|
|
32
|
-
type: 'withdraw';
|
|
33
|
-
usdc: string;
|
|
34
|
-
fee?: string;
|
|
35
|
-
};
|
|
36
|
-
export type HlLiquidatedPosition = {
|
|
37
|
-
coin: string;
|
|
38
|
-
szi: string;
|
|
39
|
-
};
|
|
40
|
-
export type HlLiquidationDelta = {
|
|
41
|
-
type: 'liquidation';
|
|
42
|
-
liquidatedNtlPos?: string;
|
|
43
|
-
accountValue?: string;
|
|
44
|
-
leverageType: string;
|
|
45
|
-
liquidatedPositions?: HlLiquidatedPosition[];
|
|
46
|
-
};
|
|
47
|
-
export type HlLedgerDelta = HlSpotTransferDelta | HlSendAssetDelta | HlDepositDelta | HlWithdrawDelta | HlLiquidationDelta | {
|
|
27
|
+
export type HlLedgerDelta = HlSpotTransferDelta | HlSendAssetDelta | {
|
|
48
28
|
type: string;
|
|
49
29
|
usdc?: string;
|
|
50
30
|
[key: string]: unknown;
|
|
51
31
|
};
|
|
52
32
|
export declare const isSpotTransferDelta: (delta: HlLedgerDelta) => delta is HlSpotTransferDelta;
|
|
53
33
|
export declare const isSendAssetDelta: (delta: HlLedgerDelta) => delta is HlSendAssetDelta;
|
|
54
|
-
export declare const isDepositDelta: (delta: HlLedgerDelta) => delta is HlDepositDelta;
|
|
55
|
-
export declare const isWithdrawDelta: (delta: HlLedgerDelta) => delta is HlWithdrawDelta;
|
|
56
|
-
export declare const isLiquidationDelta: (delta: HlLedgerDelta) => delta is HlLiquidationDelta;
|
|
57
34
|
export type HlLedgerUpdate = {
|
|
58
35
|
time: number;
|
|
59
36
|
hash: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAWnC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAgBD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAOD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAWnC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,E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,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,cAAc,CAAA;CACtB,CAAA;AAGD,MAAM,MAAM,aAAa,GAAG,eAAe,EAAE,CAAA"}
|
package/dist/cjs/types/ledger.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isSendAssetDelta = exports.isSpotTransferDelta = void 0;
|
|
4
4
|
const isSpotTransferDelta = (delta) => delta.type === 'spotTransfer';
|
|
5
5
|
exports.isSpotTransferDelta = isSpotTransferDelta;
|
|
6
6
|
const isSendAssetDelta = (delta) => delta.type === 'send';
|
|
7
7
|
exports.isSendAssetDelta = isSendAssetDelta;
|
|
8
|
-
const hasUsdcAmount = (delta) => typeof delta.usdc === 'string';
|
|
9
|
-
const isDepositDelta = (delta) => delta.type === 'deposit' && hasUsdcAmount(delta);
|
|
10
|
-
exports.isDepositDelta = isDepositDelta;
|
|
11
|
-
const isWithdrawDelta = (delta) => delta.type === 'withdraw' && hasUsdcAmount(delta);
|
|
12
|
-
exports.isWithdrawDelta = isWithdrawDelta;
|
|
13
|
-
const isLiquidationDelta = (delta) => delta.type === 'liquidation';
|
|
14
|
-
exports.isLiquidationDelta = isLiquidationDelta;
|
|
15
8
|
//# sourceMappingURL=ledger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":";;;AAyEO,MAAM,mBAAmB,GAAG,CACjC,KAAoB,EACU,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,cAAc,CAAA;AAFnD,QAAA,mBAAmB,uBAEgC;AAQzD,MAAM,gBAAgB,GAAG,CAC9B,KAAoB,EACO,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAA;AAFxC,QAAA,gBAAgB,oBAEwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapActivity.d.ts","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAEf,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"mapActivity.d.ts","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAEf,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAYxE,eAAO,MAAM,cAAc,GACzB,OAAO,cAAc,EACrB,aAAa,MAAM,EACnB,gBAAgB,MAAM,EACtB,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,KAC7C,YAAY,GAAG,IA0IjB,CAAA;AAYD,eAAO,MAAM,kBAAkB,GAC7B,OAAO,eAAe,EACtB,aAAa,MAAM,EACnB,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,KAC7C,eAYF,CAAA"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mapFundingActivity = exports.mapLedgerEntry = void 0;
|
|
4
4
|
const perps_types_1 = require("@lifi/perps-types");
|
|
5
5
|
const index_js_1 = require("../types/index.js");
|
|
6
|
-
const HL_COLLATERAL_SYMBOL = 'USDC';
|
|
7
6
|
const mapLedgerEntry = (entry, providerKey, queriedAddress, resolveMarket) => {
|
|
8
7
|
const { delta } = entry;
|
|
9
8
|
const base = {
|
|
@@ -15,9 +14,6 @@ const mapLedgerEntry = (entry, providerKey, queriedAddress, resolveMarket) => {
|
|
|
15
14
|
const queried = queriedAddress.toLowerCase();
|
|
16
15
|
const sender = delta.user.toLowerCase();
|
|
17
16
|
const recipient = delta.destination.toLowerCase();
|
|
18
|
-
if (sender === recipient && sender === queried) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
17
|
const direction = queried === sender ? 'OUT' : 'IN';
|
|
22
18
|
const counterpartyAddress = direction === 'OUT' ? recipient : sender;
|
|
23
19
|
const meta = {
|
|
@@ -80,51 +76,47 @@ const mapLedgerEntry = (entry, providerKey, queriedAddress, resolveMarket) => {
|
|
|
80
76
|
: undefined,
|
|
81
77
|
};
|
|
82
78
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return
|
|
79
|
+
switch (delta.type) {
|
|
80
|
+
case 'deposit':
|
|
81
|
+
return {
|
|
82
|
+
...base,
|
|
83
|
+
type: perps_types_1.ActivityType.DEPOSIT,
|
|
84
|
+
amount: delta.usdc ?? '0',
|
|
85
|
+
explorerLink: entry.hash
|
|
86
|
+
? `https://scan.li.fi/tx/${entry.hash}`
|
|
87
|
+
: undefined,
|
|
88
|
+
};
|
|
89
|
+
case 'withdraw':
|
|
90
|
+
return {
|
|
91
|
+
...base,
|
|
92
|
+
type: perps_types_1.ActivityType.WITHDRAWAL,
|
|
93
|
+
amount: delta.usdc ?? '0',
|
|
94
|
+
fee: delta.fee ?? '0',
|
|
95
|
+
explorerLink: entry.hash
|
|
96
|
+
? `https://scan.li.fi/tx/${entry.hash}`
|
|
97
|
+
: undefined,
|
|
98
|
+
};
|
|
99
|
+
case 'liquidation': {
|
|
100
|
+
const d = delta;
|
|
101
|
+
const liquidatedPositions = (d.liquidatedPositions ?? []).map((p) => ({
|
|
102
|
+
market: resolveMarket(p.coin),
|
|
103
|
+
size: p.szi,
|
|
104
|
+
}));
|
|
105
|
+
if (liquidatedPositions.length === 0) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
...base,
|
|
110
|
+
type: perps_types_1.ActivityType.LIQUIDATION,
|
|
111
|
+
liquidatedNotionalPosition: d.liquidatedNtlPos,
|
|
112
|
+
accountValue: d.accountValue,
|
|
113
|
+
leverageType: d.leverageType,
|
|
114
|
+
liquidatedPositions,
|
|
115
|
+
};
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
type: perps_types_1.ActivityType.LIQUIDATION,
|
|
117
|
-
...(delta.liquidatedNtlPos === undefined
|
|
118
|
-
? {}
|
|
119
|
-
: { liquidatedNotionalPosition: delta.liquidatedNtlPos }),
|
|
120
|
-
...(delta.accountValue === undefined
|
|
121
|
-
? {}
|
|
122
|
-
: { accountValue: delta.accountValue }),
|
|
123
|
-
leverageType: delta.leverageType,
|
|
124
|
-
liquidatedPositions,
|
|
125
|
-
};
|
|
117
|
+
default:
|
|
118
|
+
return null;
|
|
126
119
|
}
|
|
127
|
-
return null;
|
|
128
120
|
};
|
|
129
121
|
exports.mapLedgerEntry = mapLedgerEntry;
|
|
130
122
|
const mapFundingActivity = (entry, providerKey, resolveMarket) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapActivity.js","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":";;;AASA,mDAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"mapActivity.js","sourceRoot":"","sources":["../../../src/utils/mapActivity.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,IAAI,CAAC,EAAE,YAAY,EAAE,CAAA;CACtB;AAmDD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,GACtB,oBAAoB,kBAAkB,EACtC,QAAQ,iBAAiB,EACzB,UAAU,iBAAiB,KAC1B,OAAO,CAAC,kBAAkB,CAuD5B,CAAA"}
|
|
@@ -3,11 +3,6 @@ import { ActivityType } from '@lifi/perps-types';
|
|
|
3
3
|
import { DEFAULT_HISTORY_LIMIT, MAX_HISTORY_LIMIT, NINETY_DAYS_MS, PROVIDER_KEY, } from '../constants.js';
|
|
4
4
|
import { mapFundingActivity, mapLedgerEntry } from '../utils/index.js';
|
|
5
5
|
import { hlInfoOptions, infoRequest, } from '../utils/infoClient.js';
|
|
6
|
-
const MARKET_BEARING_TYPES = new Set([
|
|
7
|
-
ActivityType.FUNDING,
|
|
8
|
-
ActivityType.LIQUIDATION,
|
|
9
|
-
]);
|
|
10
|
-
const needsMarkets = (typeFilter) => !typeFilter || typeFilter.some((t) => MARKET_BEARING_TYPES.has(t));
|
|
11
6
|
const fetchActivityData = async (apiUrl, typeFilter, timeParams, resolveMarket, options) => {
|
|
12
7
|
const needLedger = !typeFilter || typeFilter.some((t) => t !== ActivityType.FUNDING);
|
|
13
8
|
const needFunding = !typeFilter || typeFilter.includes(ActivityType.FUNDING);
|
|
@@ -44,11 +39,7 @@ const fetchActivityData = async (apiUrl, typeFilter, timeParams, resolveMarket,
|
|
|
44
39
|
*/
|
|
45
40
|
export const getActivity = async ({ client, apiUrl }, params, options) => {
|
|
46
41
|
const registry = getMarketRegistry(client, PROVIDER_KEY);
|
|
47
|
-
|
|
48
|
-
// request must not pull the market list.
|
|
49
|
-
if (needsMarkets(params.type)) {
|
|
50
|
-
await registry.sync();
|
|
51
|
-
}
|
|
42
|
+
await registry.sync();
|
|
52
43
|
const infoOpts = hlInfoOptions(client, options);
|
|
53
44
|
const limit = Math.min(params.limit ?? DEFAULT_HISTORY_LIMIT, MAX_HISTORY_LIMIT);
|
|
54
45
|
const startTime = params.startTime ?? Date.now() - NINETY_DAYS_MS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getActivity.js","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,iBAAiB,CAAA;AAM3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,iBAAiB,CAAA;AAMxB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EACL,aAAa,EAEb,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAqB/B,MAAM,
|
|
1
|
+
{"version":3,"file":"getActivity.js","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,iBAAiB,CAAA;AAM3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,iBAAiB,CAAA;AAMxB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EACL,aAAa,EAEb,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAqB/B,MAAM,iBAAiB,GAAG,KAAK,EAC7B,MAAc,EACd,UAAsC,EACtC,UAAkE,EAClE,aAA8C,EAC9C,OAA4B,EACH,EAAE;IAC3B,MAAM,UAAU,GACd,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,OAAO,CAAC,CAAA;IACnE,MAAM,WAAW,GAAG,CAAC,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,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,GACZ,MAAM,CAAC,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,MAAM,CAAC,MAAM,CACX,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;YAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAO,EAAE,EAAE,CAAC,CACtC,CAAA;IAEP,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAA;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IAEtC,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,KAAK;QACL,UAAU,EAAE;YACV,KAAK;YACL,OAAO;YACP,MAAM,EACJ,KAAK,CAAC,MAAM,GAAG,CAAC;gBACd,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC/D,CAAC,CAAC,SAAS;SAChB;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -45,53 +45,12 @@ export type HlSendAssetDelta = {
|
|
|
45
45
|
nonce: number;
|
|
46
46
|
feeToken: string;
|
|
47
47
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Hyperliquid `deposit` ledger delta. Perp-collateral deposits are always
|
|
50
|
-
* USDC-denominated, which is why the amount arrives in a field named `usdc`.
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export type HlDepositDelta = {
|
|
54
|
-
type: 'deposit';
|
|
55
|
-
usdc: string;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Hyperliquid `withdraw` ledger delta. `fee` is denominated in the withdrawn
|
|
59
|
-
* asset (USDC) and is absent when the venue charges none.
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
export type HlWithdrawDelta = {
|
|
63
|
-
type: 'withdraw';
|
|
64
|
-
usdc: string;
|
|
65
|
-
fee?: string;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* One position closed by a Hyperliquid liquidation. `coin` is the venue market
|
|
69
|
-
* key and `szi` the signed position size.
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
export type HlLiquidatedPosition = {
|
|
73
|
-
coin: string;
|
|
74
|
-
szi: string;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Hyperliquid `liquidation` ledger delta. A cross-margin cascade reports every
|
|
78
|
-
* closed position in `liquidatedPositions`, so the venue itself carries the
|
|
79
|
-
* grouping and no timestamp heuristic is needed.
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export type HlLiquidationDelta = {
|
|
83
|
-
type: 'liquidation';
|
|
84
|
-
liquidatedNtlPos?: string;
|
|
85
|
-
accountValue?: string;
|
|
86
|
-
leverageType: string;
|
|
87
|
-
liquidatedPositions?: HlLiquidatedPosition[];
|
|
88
|
-
};
|
|
89
48
|
/**
|
|
90
49
|
* Union of known Hyperliquid non-funding ledger deltas plus an open fallback
|
|
91
50
|
* for endpoint variants the provider does not map.
|
|
92
51
|
* @public
|
|
93
52
|
*/
|
|
94
|
-
export type HlLedgerDelta = HlSpotTransferDelta | HlSendAssetDelta |
|
|
53
|
+
export type HlLedgerDelta = HlSpotTransferDelta | HlSendAssetDelta | {
|
|
95
54
|
type: string;
|
|
96
55
|
usdc?: string;
|
|
97
56
|
[key: string]: unknown;
|
|
@@ -111,25 +70,6 @@ export declare const isSpotTransferDelta: (delta: HlLedgerDelta) => delta is HlS
|
|
|
111
70
|
* @public
|
|
112
71
|
*/
|
|
113
72
|
export declare const isSendAssetDelta: (delta: HlLedgerDelta) => delta is HlSendAssetDelta;
|
|
114
|
-
/**
|
|
115
|
-
* Type guard for `HlDepositDelta`. The amount is part of the guard: a deposit
|
|
116
|
-
* row without one identifies no movement, and reporting it as a zero amount
|
|
117
|
-
* would read as a real zero-value deposit.
|
|
118
|
-
* @public
|
|
119
|
-
*/
|
|
120
|
-
export declare const isDepositDelta: (delta: HlLedgerDelta) => delta is HlDepositDelta;
|
|
121
|
-
/**
|
|
122
|
-
* Type guard for `HlWithdrawDelta`. Same amount-bearing requirement as
|
|
123
|
-
* `isDepositDelta`.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
export declare const isWithdrawDelta: (delta: HlLedgerDelta) => delta is HlWithdrawDelta;
|
|
127
|
-
/**
|
|
128
|
-
* Type guard for `HlLiquidationDelta`. Same catch-all-arm caveat as
|
|
129
|
-
* `isSpotTransferDelta`.
|
|
130
|
-
* @public
|
|
131
|
-
*/
|
|
132
|
-
export declare const isLiquidationDelta: (delta: HlLedgerDelta) => delta is HlLiquidationDelta;
|
|
133
73
|
/**
|
|
134
74
|
* One timestamped non-funding ledger update. `time` is milliseconds since
|
|
135
75
|
* epoch and `hash` is the upstream transaction identifier.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAInC;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAA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MAAM,CAAA;CACjB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,gBAAgB,GAChB;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,aAAa,KACnB,KAAK,IAAI,mBAAoD,CAAA;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,aAAa,KACnB,KAAK,IAAI,gBAAyC,CAAA;AAErD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,aAAa,CAAA;CACrB,CAAA;AAED,+DAA+D;AAC/D,MAAM,MAAM,6BAA6B,GAAG,cAAc,EAAE,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,cAAc,CAAA;CACtB,CAAA;AAED,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,eAAe,EAAE,CAAA"}
|
package/dist/esm/types/ledger.js
CHANGED
|
@@ -13,26 +13,4 @@ export const isSpotTransferDelta = (delta) => delta.type === 'spotTransfer';
|
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
15
|
export const isSendAssetDelta = (delta) => delta.type === 'send';
|
|
16
|
-
// `usdc` is declared only on the union's catch-all arm, so reading it off the
|
|
17
|
-
// union needs a widening read before the discriminant has narrowed the type.
|
|
18
|
-
const hasUsdcAmount = (delta) => typeof delta.usdc === 'string';
|
|
19
|
-
/**
|
|
20
|
-
* Type guard for `HlDepositDelta`. The amount is part of the guard: a deposit
|
|
21
|
-
* row without one identifies no movement, and reporting it as a zero amount
|
|
22
|
-
* would read as a real zero-value deposit.
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export const isDepositDelta = (delta) => delta.type === 'deposit' && hasUsdcAmount(delta);
|
|
26
|
-
/**
|
|
27
|
-
* Type guard for `HlWithdrawDelta`. Same amount-bearing requirement as
|
|
28
|
-
* `isDepositDelta`.
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export const isWithdrawDelta = (delta) => delta.type === 'withdraw' && hasUsdcAmount(delta);
|
|
32
|
-
/**
|
|
33
|
-
* Type guard for `HlLiquidationDelta`. Same catch-all-arm caveat as
|
|
34
|
-
* `isSpotTransferDelta`.
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export const isLiquidationDelta = (delta) => delta.type === 'liquidation';
|
|
38
16
|
//# sourceMappingURL=ledger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings":"AAkEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,KAAoB,EACU,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,cAAc,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAoB,EACO,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAA"}
|
|
@@ -5,8 +5,8 @@ import type { HlFundingUpdate, HlLedgerUpdate } from '../types/index.js';
|
|
|
5
5
|
*
|
|
6
6
|
* Direction for `spotTransfer` and `sendAsset` is derived from
|
|
7
7
|
* `queriedAddress` matching the delta's `user` (OUT) or `destination` (IN).
|
|
8
|
-
* Returns null for unsupported delta types and for same-
|
|
9
|
-
* `user === destination === queriedAddress
|
|
8
|
+
* Returns null for unsupported delta types and for same-user `sendAsset`
|
|
9
|
+
* dex moves (where `user === destination === queriedAddress`).
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export declare const mapLedgerEntry: (entry: HlLedgerUpdate, providerKey: string, queriedAddress: string, resolveMarket: (coin: string) => MarketDisplay) => ActivityItem | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapActivity.d.ts","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAEf,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"mapActivity.d.ts","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAEf,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGxE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,cAAc,EACrB,aAAa,MAAM,EACnB,gBAAgB,MAAM,EACtB,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,KAC7C,YAAY,GAAG,IA0IjB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,eAAe,EACtB,aAAa,MAAM,EACnB,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,KAC7C,eAYF,CAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ActivityType } from '@lifi/perps-types';
|
|
2
|
-
import {
|
|
3
|
-
/** Hyperliquid settles every perp deposit and withdrawal in USDC. */
|
|
4
|
-
const HL_COLLATERAL_SYMBOL = 'USDC';
|
|
2
|
+
import { isSendAssetDelta, isSpotTransferDelta } from '../types/index.js';
|
|
5
3
|
/**
|
|
6
4
|
* Map a Hyperliquid non-funding ledger entry to an ActivityItem.
|
|
7
5
|
*
|
|
8
6
|
* Direction for `spotTransfer` and `sendAsset` is derived from
|
|
9
7
|
* `queriedAddress` matching the delta's `user` (OUT) or `destination` (IN).
|
|
10
|
-
* Returns null for unsupported delta types and for same-
|
|
11
|
-
* `user === destination === queriedAddress
|
|
8
|
+
* Returns null for unsupported delta types and for same-user `sendAsset`
|
|
9
|
+
* dex moves (where `user === destination === queriedAddress`).
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
12
|
export const mapLedgerEntry = (entry, providerKey, queriedAddress, resolveMarket) => {
|
|
@@ -25,11 +23,6 @@ export const mapLedgerEntry = (entry, providerKey, queriedAddress, resolveMarket
|
|
|
25
23
|
const queried = queriedAddress.toLowerCase();
|
|
26
24
|
const sender = delta.user.toLowerCase();
|
|
27
25
|
const recipient = delta.destination.toLowerCase();
|
|
28
|
-
// A transfer reports a movement between two accounts. A row whose sender
|
|
29
|
-
// and recipient are the queried account moves nothing between accounts.
|
|
30
|
-
if (sender === recipient && sender === queried) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
26
|
const direction = queried === sender ? 'OUT' : 'IN';
|
|
34
27
|
const counterpartyAddress = direction === 'OUT' ? recipient : sender;
|
|
35
28
|
const meta = {
|
|
@@ -96,54 +89,50 @@ export const mapLedgerEntry = (entry, providerKey, queriedAddress, resolveMarket
|
|
|
96
89
|
: undefined,
|
|
97
90
|
};
|
|
98
91
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return
|
|
92
|
+
switch (delta.type) {
|
|
93
|
+
case 'deposit':
|
|
94
|
+
return {
|
|
95
|
+
...base,
|
|
96
|
+
type: ActivityType.DEPOSIT,
|
|
97
|
+
amount: delta.usdc ?? '0',
|
|
98
|
+
explorerLink: entry.hash
|
|
99
|
+
? `https://scan.li.fi/tx/${entry.hash}`
|
|
100
|
+
: undefined,
|
|
101
|
+
};
|
|
102
|
+
case 'withdraw':
|
|
103
|
+
return {
|
|
104
|
+
...base,
|
|
105
|
+
type: ActivityType.WITHDRAWAL,
|
|
106
|
+
amount: delta.usdc ?? '0',
|
|
107
|
+
fee: delta.fee ?? '0',
|
|
108
|
+
explorerLink: entry.hash
|
|
109
|
+
? `https://scan.li.fi/tx/${entry.hash}`
|
|
110
|
+
: undefined,
|
|
111
|
+
};
|
|
112
|
+
case 'liquidation': {
|
|
113
|
+
const d = delta;
|
|
114
|
+
const liquidatedPositions = (d.liquidatedPositions ?? []).map((p) => ({
|
|
115
|
+
market: resolveMarket(p.coin),
|
|
116
|
+
size: p.szi,
|
|
117
|
+
}));
|
|
118
|
+
// Liquidation rows must point to at least one market. Drop entries with
|
|
119
|
+
// missing/empty positions so downstream consumers can rely on that
|
|
120
|
+
// invariant and avoid rendering a market-less liquidation card.
|
|
121
|
+
if (liquidatedPositions.length === 0) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
...base,
|
|
126
|
+
type: ActivityType.LIQUIDATION,
|
|
127
|
+
liquidatedNotionalPosition: d.liquidatedNtlPos,
|
|
128
|
+
accountValue: d.accountValue,
|
|
129
|
+
leverageType: d.leverageType,
|
|
130
|
+
liquidatedPositions,
|
|
131
|
+
};
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type: ActivityType.LIQUIDATION,
|
|
136
|
-
...(delta.liquidatedNtlPos === undefined
|
|
137
|
-
? {}
|
|
138
|
-
: { liquidatedNotionalPosition: delta.liquidatedNtlPos }),
|
|
139
|
-
...(delta.accountValue === undefined
|
|
140
|
-
? {}
|
|
141
|
-
: { accountValue: delta.accountValue }),
|
|
142
|
-
leverageType: delta.leverageType,
|
|
143
|
-
liquidatedPositions,
|
|
144
|
-
};
|
|
133
|
+
default:
|
|
134
|
+
return null;
|
|
145
135
|
}
|
|
146
|
-
return null;
|
|
147
136
|
};
|
|
148
137
|
/**
|
|
149
138
|
* Map a Hyperliquid funding ledger update to a normalized funding activity.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapActivity.js","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"mapActivity.js","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAqB,EACrB,WAAmB,EACnB,cAAsB,EACtB,aAA8C,EACzB,EAAE;IACvB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;IACvB,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,KAAK,CAAC,IAAI;QACd,QAAQ,EAAE,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,kBAAkB,CAuD5B,CAAA"}
|
|
@@ -45,53 +45,12 @@ export type HlSendAssetDelta = {
|
|
|
45
45
|
nonce: number;
|
|
46
46
|
feeToken: string;
|
|
47
47
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Hyperliquid `deposit` ledger delta. Perp-collateral deposits are always
|
|
50
|
-
* USDC-denominated, which is why the amount arrives in a field named `usdc`.
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export type HlDepositDelta = {
|
|
54
|
-
type: 'deposit';
|
|
55
|
-
usdc: string;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Hyperliquid `withdraw` ledger delta. `fee` is denominated in the withdrawn
|
|
59
|
-
* asset (USDC) and is absent when the venue charges none.
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
export type HlWithdrawDelta = {
|
|
63
|
-
type: 'withdraw';
|
|
64
|
-
usdc: string;
|
|
65
|
-
fee?: string;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* One position closed by a Hyperliquid liquidation. `coin` is the venue market
|
|
69
|
-
* key and `szi` the signed position size.
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
export type HlLiquidatedPosition = {
|
|
73
|
-
coin: string;
|
|
74
|
-
szi: string;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Hyperliquid `liquidation` ledger delta. A cross-margin cascade reports every
|
|
78
|
-
* closed position in `liquidatedPositions`, so the venue itself carries the
|
|
79
|
-
* grouping and no timestamp heuristic is needed.
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export type HlLiquidationDelta = {
|
|
83
|
-
type: 'liquidation';
|
|
84
|
-
liquidatedNtlPos?: string;
|
|
85
|
-
accountValue?: string;
|
|
86
|
-
leverageType: string;
|
|
87
|
-
liquidatedPositions?: HlLiquidatedPosition[];
|
|
88
|
-
};
|
|
89
48
|
/**
|
|
90
49
|
* Union of known Hyperliquid non-funding ledger deltas plus an open fallback
|
|
91
50
|
* for endpoint variants the provider does not map.
|
|
92
51
|
* @public
|
|
93
52
|
*/
|
|
94
|
-
export type HlLedgerDelta = HlSpotTransferDelta | HlSendAssetDelta |
|
|
53
|
+
export type HlLedgerDelta = HlSpotTransferDelta | HlSendAssetDelta | {
|
|
95
54
|
type: string;
|
|
96
55
|
usdc?: string;
|
|
97
56
|
[key: string]: unknown;
|
|
@@ -111,25 +70,6 @@ export declare const isSpotTransferDelta: (delta: HlLedgerDelta) => delta is HlS
|
|
|
111
70
|
* @public
|
|
112
71
|
*/
|
|
113
72
|
export declare const isSendAssetDelta: (delta: HlLedgerDelta) => delta is HlSendAssetDelta;
|
|
114
|
-
/**
|
|
115
|
-
* Type guard for `HlDepositDelta`. The amount is part of the guard: a deposit
|
|
116
|
-
* row without one identifies no movement, and reporting it as a zero amount
|
|
117
|
-
* would read as a real zero-value deposit.
|
|
118
|
-
* @public
|
|
119
|
-
*/
|
|
120
|
-
export declare const isDepositDelta: (delta: HlLedgerDelta) => delta is HlDepositDelta;
|
|
121
|
-
/**
|
|
122
|
-
* Type guard for `HlWithdrawDelta`. Same amount-bearing requirement as
|
|
123
|
-
* `isDepositDelta`.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
export declare const isWithdrawDelta: (delta: HlLedgerDelta) => delta is HlWithdrawDelta;
|
|
127
|
-
/**
|
|
128
|
-
* Type guard for `HlLiquidationDelta`. Same catch-all-arm caveat as
|
|
129
|
-
* `isSpotTransferDelta`.
|
|
130
|
-
* @public
|
|
131
|
-
*/
|
|
132
|
-
export declare const isLiquidationDelta: (delta: HlLedgerDelta) => delta is HlLiquidationDelta;
|
|
133
73
|
/**
|
|
134
74
|
* One timestamped non-funding ledger update. `time` is milliseconds since
|
|
135
75
|
* epoch and `hash` is the upstream transaction identifier.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../src/types/ledger.ts"],"names":[],"mappings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AM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,cAAc,CAAA;CACtB,CAAA;AAED,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,eAAe,EAAE,CAAA"}
|
|
@@ -5,8 +5,8 @@ import type { HlFundingUpdate, HlLedgerUpdate } from '../types/index.js';
|
|
|
5
5
|
*
|
|
6
6
|
* Direction for `spotTransfer` and `sendAsset` is derived from
|
|
7
7
|
* `queriedAddress` matching the delta's `user` (OUT) or `destination` (IN).
|
|
8
|
-
* Returns null for unsupported delta types and for same-
|
|
9
|
-
* `user === destination === queriedAddress
|
|
8
|
+
* Returns null for unsupported delta types and for same-user `sendAsset`
|
|
9
|
+
* dex moves (where `user === destination === queriedAddress`).
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export declare const mapLedgerEntry: (entry: HlLedgerUpdate, providerKey: string, queriedAddress: string, resolveMarket: (coin: string) => MarketDisplay) => ActivityItem | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapActivity.d.ts","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAEf,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"mapActivity.d.ts","sourceRoot":"","sources":["../../../src/utils/mapActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EAEf,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGxE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,cAAc,EACrB,aAAa,MAAM,EACnB,gBAAgB,MAAM,EACtB,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,KAC7C,YAAY,GAAG,IA0IjB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,eAAe,EACtB,aAAa,MAAM,EACnB,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,KAC7C,eAYF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk-provider-hyperliquid",
|
|
3
|
-
"version": "0.0.0-preview-
|
|
3
|
+
"version": "0.0.0-preview-cbbc415",
|
|
4
4
|
"description": "Hyperliquid provider plugin for @lifi/perps-sdk",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"big.js": "^7.0.1",
|
|
51
51
|
"viem": "^2.55.18",
|
|
52
|
-
"@lifi/perps-types": "^0.0.0-preview-
|
|
52
|
+
"@lifi/perps-types": "^0.0.0-preview-cbbc415"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@lifi/perps-sdk": "^0.0.0-preview-
|
|
55
|
+
"@lifi/perps-sdk": "^0.0.0-preview-cbbc415"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -43,14 +43,6 @@ export interface GetActivityParams {
|
|
|
43
43
|
type?: ActivityType[]
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const MARKET_BEARING_TYPES: ReadonlySet<ActivityType> = new Set([
|
|
47
|
-
ActivityType.FUNDING,
|
|
48
|
-
ActivityType.LIQUIDATION,
|
|
49
|
-
])
|
|
50
|
-
|
|
51
|
-
const needsMarkets = (typeFilter: ActivityType[] | undefined): boolean =>
|
|
52
|
-
!typeFilter || typeFilter.some((t) => MARKET_BEARING_TYPES.has(t))
|
|
53
|
-
|
|
54
46
|
const fetchActivityData = async (
|
|
55
47
|
apiUrl: string,
|
|
56
48
|
typeFilter: ActivityType[] | undefined,
|
|
@@ -118,11 +110,7 @@ export const getActivity = async (
|
|
|
118
110
|
options?: SDKRequestOptions
|
|
119
111
|
): Promise<ActivitiesResponse> => {
|
|
120
112
|
const registry = getMarketRegistry(client, PROVIDER_KEY)
|
|
121
|
-
|
|
122
|
-
// request must not pull the market list.
|
|
123
|
-
if (needsMarkets(params.type)) {
|
|
124
|
-
await registry.sync()
|
|
125
|
-
}
|
|
113
|
+
await registry.sync()
|
|
126
114
|
const infoOpts = hlInfoOptions(client, options)
|
|
127
115
|
|
|
128
116
|
const limit = Math.min(
|
package/src/types/ledger.ts
CHANGED
|
@@ -50,51 +50,6 @@ export type HlSendAssetDelta = {
|
|
|
50
50
|
feeToken: string
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* Hyperliquid `deposit` ledger delta. Perp-collateral deposits are always
|
|
55
|
-
* USDC-denominated, which is why the amount arrives in a field named `usdc`.
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export type HlDepositDelta = {
|
|
59
|
-
type: 'deposit'
|
|
60
|
-
usdc: string
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Hyperliquid `withdraw` ledger delta. `fee` is denominated in the withdrawn
|
|
65
|
-
* asset (USDC) and is absent when the venue charges none.
|
|
66
|
-
* @public
|
|
67
|
-
*/
|
|
68
|
-
export type HlWithdrawDelta = {
|
|
69
|
-
type: 'withdraw'
|
|
70
|
-
usdc: string
|
|
71
|
-
fee?: string
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* One position closed by a Hyperliquid liquidation. `coin` is the venue market
|
|
76
|
-
* key and `szi` the signed position size.
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
79
|
-
export type HlLiquidatedPosition = {
|
|
80
|
-
coin: string
|
|
81
|
-
szi: string
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Hyperliquid `liquidation` ledger delta. A cross-margin cascade reports every
|
|
86
|
-
* closed position in `liquidatedPositions`, so the venue itself carries the
|
|
87
|
-
* grouping and no timestamp heuristic is needed.
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
export type HlLiquidationDelta = {
|
|
91
|
-
type: 'liquidation'
|
|
92
|
-
liquidatedNtlPos?: string
|
|
93
|
-
accountValue?: string
|
|
94
|
-
leverageType: string
|
|
95
|
-
liquidatedPositions?: HlLiquidatedPosition[]
|
|
96
|
-
}
|
|
97
|
-
|
|
98
53
|
/**
|
|
99
54
|
* Union of known Hyperliquid non-funding ledger deltas plus an open fallback
|
|
100
55
|
* for endpoint variants the provider does not map.
|
|
@@ -103,9 +58,6 @@ export type HlLiquidationDelta = {
|
|
|
103
58
|
export type HlLedgerDelta =
|
|
104
59
|
| HlSpotTransferDelta
|
|
105
60
|
| HlSendAssetDelta
|
|
106
|
-
| HlDepositDelta
|
|
107
|
-
| HlWithdrawDelta
|
|
108
|
-
| HlLiquidationDelta
|
|
109
61
|
| {
|
|
110
62
|
type: string
|
|
111
63
|
usdc?: string
|
|
@@ -133,38 +85,6 @@ export const isSendAssetDelta = (
|
|
|
133
85
|
delta: HlLedgerDelta
|
|
134
86
|
): delta is HlSendAssetDelta => delta.type === 'send'
|
|
135
87
|
|
|
136
|
-
// `usdc` is declared only on the union's catch-all arm, so reading it off the
|
|
137
|
-
// union needs a widening read before the discriminant has narrowed the type.
|
|
138
|
-
const hasUsdcAmount = (delta: HlLedgerDelta): boolean =>
|
|
139
|
-
typeof (delta as { usdc?: unknown }).usdc === 'string'
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Type guard for `HlDepositDelta`. The amount is part of the guard: a deposit
|
|
143
|
-
* row without one identifies no movement, and reporting it as a zero amount
|
|
144
|
-
* would read as a real zero-value deposit.
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
export const isDepositDelta = (delta: HlLedgerDelta): delta is HlDepositDelta =>
|
|
148
|
-
delta.type === 'deposit' && hasUsdcAmount(delta)
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Type guard for `HlWithdrawDelta`. Same amount-bearing requirement as
|
|
152
|
-
* `isDepositDelta`.
|
|
153
|
-
* @public
|
|
154
|
-
*/
|
|
155
|
-
export const isWithdrawDelta = (
|
|
156
|
-
delta: HlLedgerDelta
|
|
157
|
-
): delta is HlWithdrawDelta => delta.type === 'withdraw' && hasUsdcAmount(delta)
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Type guard for `HlLiquidationDelta`. Same catch-all-arm caveat as
|
|
161
|
-
* `isSpotTransferDelta`.
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
export const isLiquidationDelta = (
|
|
165
|
-
delta: HlLedgerDelta
|
|
166
|
-
): delta is HlLiquidationDelta => delta.type === 'liquidation'
|
|
167
|
-
|
|
168
88
|
/**
|
|
169
89
|
* One timestamped non-funding ledger update. `time` is milliseconds since
|
|
170
90
|
* epoch and `hash` is the upstream transaction identifier.
|
package/src/utils/mapActivity.ts
CHANGED
|
@@ -9,24 +9,15 @@ import type {
|
|
|
9
9
|
} from '@lifi/perps-types'
|
|
10
10
|
import { ActivityType } from '@lifi/perps-types'
|
|
11
11
|
import type { HlFundingUpdate, HlLedgerUpdate } from '../types/index.js'
|
|
12
|
-
import {
|
|
13
|
-
isDepositDelta,
|
|
14
|
-
isLiquidationDelta,
|
|
15
|
-
isSendAssetDelta,
|
|
16
|
-
isSpotTransferDelta,
|
|
17
|
-
isWithdrawDelta,
|
|
18
|
-
} from '../types/index.js'
|
|
19
|
-
|
|
20
|
-
/** Hyperliquid settles every perp deposit and withdrawal in USDC. */
|
|
21
|
-
const HL_COLLATERAL_SYMBOL = 'USDC'
|
|
12
|
+
import { isSendAssetDelta, isSpotTransferDelta } from '../types/index.js'
|
|
22
13
|
|
|
23
14
|
/**
|
|
24
15
|
* Map a Hyperliquid non-funding ledger entry to an ActivityItem.
|
|
25
16
|
*
|
|
26
17
|
* Direction for `spotTransfer` and `sendAsset` is derived from
|
|
27
18
|
* `queriedAddress` matching the delta's `user` (OUT) or `destination` (IN).
|
|
28
|
-
* Returns null for unsupported delta types and for same-
|
|
29
|
-
* `user === destination === queriedAddress
|
|
19
|
+
* Returns null for unsupported delta types and for same-user `sendAsset`
|
|
20
|
+
* dex moves (where `user === destination === queriedAddress`).
|
|
30
21
|
* @public
|
|
31
22
|
*/
|
|
32
23
|
export const mapLedgerEntry = (
|
|
@@ -49,13 +40,6 @@ export const mapLedgerEntry = (
|
|
|
49
40
|
const queried = queriedAddress.toLowerCase()
|
|
50
41
|
const sender = delta.user.toLowerCase()
|
|
51
42
|
const recipient = delta.destination.toLowerCase()
|
|
52
|
-
|
|
53
|
-
// A transfer reports a movement between two accounts. A row whose sender
|
|
54
|
-
// and recipient are the queried account moves nothing between accounts.
|
|
55
|
-
if (sender === recipient && sender === queried) {
|
|
56
|
-
return null
|
|
57
|
-
}
|
|
58
|
-
|
|
59
43
|
const direction: 'IN' | 'OUT' = queried === sender ? 'OUT' : 'IN'
|
|
60
44
|
const counterpartyAddress = direction === 'OUT' ? recipient : sender
|
|
61
45
|
const meta: Record<string, unknown> = {
|
|
@@ -126,57 +110,59 @@ export const mapLedgerEntry = (
|
|
|
126
110
|
} satisfies TransferActivity
|
|
127
111
|
}
|
|
128
112
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
113
|
+
switch (delta.type) {
|
|
114
|
+
case 'deposit':
|
|
115
|
+
return {
|
|
116
|
+
...base,
|
|
117
|
+
type: ActivityType.DEPOSIT,
|
|
118
|
+
amount: delta.usdc ?? '0',
|
|
119
|
+
explorerLink: entry.hash
|
|
120
|
+
? `https://scan.li.fi/tx/${entry.hash}`
|
|
121
|
+
: undefined,
|
|
122
|
+
} satisfies DepositActivity
|
|
140
123
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} satisfies WithdrawalActivity
|
|
152
|
-
}
|
|
124
|
+
case 'withdraw':
|
|
125
|
+
return {
|
|
126
|
+
...base,
|
|
127
|
+
type: ActivityType.WITHDRAWAL,
|
|
128
|
+
amount: delta.usdc ?? '0',
|
|
129
|
+
fee: (delta as { fee?: string }).fee ?? '0',
|
|
130
|
+
explorerLink: entry.hash
|
|
131
|
+
? `https://scan.li.fi/tx/${entry.hash}`
|
|
132
|
+
: undefined,
|
|
133
|
+
} satisfies WithdrawalActivity
|
|
153
134
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
135
|
+
case 'liquidation': {
|
|
136
|
+
const d = delta as unknown as {
|
|
137
|
+
type: string
|
|
138
|
+
liquidatedNtlPos: string
|
|
139
|
+
accountValue: string
|
|
140
|
+
leverageType: string
|
|
141
|
+
liquidatedPositions?: { coin: string; szi: string }[]
|
|
142
|
+
}
|
|
143
|
+
const liquidatedPositions = (d.liquidatedPositions ?? []).map((p) => ({
|
|
144
|
+
market: resolveMarket(p.coin),
|
|
145
|
+
size: p.szi,
|
|
146
|
+
}))
|
|
147
|
+
// Liquidation rows must point to at least one market. Drop entries with
|
|
148
|
+
// missing/empty positions so downstream consumers can rely on that
|
|
149
|
+
// invariant and avoid rendering a market-less liquidation card.
|
|
150
|
+
if (liquidatedPositions.length === 0) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
...base,
|
|
155
|
+
type: ActivityType.LIQUIDATION,
|
|
156
|
+
liquidatedNotionalPosition: d.liquidatedNtlPos,
|
|
157
|
+
accountValue: d.accountValue,
|
|
158
|
+
leverageType: d.leverageType,
|
|
159
|
+
liquidatedPositions,
|
|
160
|
+
} satisfies LiquidationActivity
|
|
164
161
|
}
|
|
165
|
-
return {
|
|
166
|
-
...base,
|
|
167
|
-
type: ActivityType.LIQUIDATION,
|
|
168
|
-
...(delta.liquidatedNtlPos === undefined
|
|
169
|
-
? {}
|
|
170
|
-
: { liquidatedNotionalPosition: delta.liquidatedNtlPos }),
|
|
171
|
-
...(delta.accountValue === undefined
|
|
172
|
-
? {}
|
|
173
|
-
: { accountValue: delta.accountValue }),
|
|
174
|
-
leverageType: delta.leverageType,
|
|
175
|
-
liquidatedPositions,
|
|
176
|
-
} satisfies LiquidationActivity
|
|
177
|
-
}
|
|
178
162
|
|
|
179
|
-
|
|
163
|
+
default:
|
|
164
|
+
return null
|
|
165
|
+
}
|
|
180
166
|
}
|
|
181
167
|
|
|
182
168
|
/**
|