@basedone/core 0.0.8 → 0.1.0
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/chunk-KH53SPJC.mjs +13 -0
- package/dist/index.d.mts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +80 -6
- package/dist/index.mjs +76 -5
- package/dist/meta-44Z4QO5K.mjs +1474 -0
- package/dist/meta-VES4BWNR.mjs +1355 -0
- package/dist/perpDexs-BE7YAC5W.mjs +17 -0
- package/dist/perpDexs-F3JQZZLH.mjs +537 -0
- package/dist/spotMeta-HRQNZMVY.mjs +6442 -0
- package/dist/spotMeta-SHXGTDWD.mjs +26559 -0
- package/dist/staticMeta-2HYATSVU.mjs +25 -0
- package/dist/staticMeta-PLKPPG23.mjs +23 -0
- package/index.ts +1 -0
- package/lib/cloid/cloid.ts +4 -0
- package/lib/hip3/utils.ts +89 -0
- package/lib/meta/metadata.ts +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./chunk-KH53SPJC.mjs";
|
|
2
|
+
|
|
3
|
+
// lib/meta/data/mainnet/staticMeta.json
|
|
4
|
+
var coins = {
|
|
5
|
+
"xyz:XYZ100": {
|
|
6
|
+
imageUrl: "https://app.based.one/hip3/xyz/xyz100.webp",
|
|
7
|
+
displayName: "Nasdaq-100"
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var dexs = {
|
|
11
|
+
xyz: {
|
|
12
|
+
imageUrl: "",
|
|
13
|
+
displayName: "Trade.xyz",
|
|
14
|
+
accountName: "Equities"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var staticMeta_default = {
|
|
18
|
+
coins,
|
|
19
|
+
dexs
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
coins,
|
|
23
|
+
staticMeta_default as default,
|
|
24
|
+
dexs
|
|
25
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./chunk-KH53SPJC.mjs";
|
|
2
|
+
|
|
3
|
+
// lib/meta/data/testnet/staticMeta.json
|
|
4
|
+
var coins = {
|
|
5
|
+
"rrrrr:BTC": {
|
|
6
|
+
displayName: "BTCe"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var dexs = {
|
|
10
|
+
rrrrr: {
|
|
11
|
+
displayName: "Hyena",
|
|
12
|
+
accountName: "USDe"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var staticMeta_default = {
|
|
16
|
+
coins,
|
|
17
|
+
dexs
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
coins,
|
|
21
|
+
staticMeta_default as default,
|
|
22
|
+
dexs
|
|
23
|
+
};
|
package/index.ts
CHANGED
package/lib/cloid/cloid.ts
CHANGED
|
@@ -255,6 +255,7 @@ export const CloidClientCode = {
|
|
|
255
255
|
Chase: 6,
|
|
256
256
|
Desktop: 7,
|
|
257
257
|
API: 8,
|
|
258
|
+
Stream: 9,
|
|
258
259
|
} as const;
|
|
259
260
|
type ClientCodeType = keyof typeof CloidClientCode;
|
|
260
261
|
|
|
@@ -270,6 +271,7 @@ export const CloidClientCodeNameById: Record<number, ClientCodeType> = {
|
|
|
270
271
|
[CloidClientCode.Chase]: "Chase",
|
|
271
272
|
[CloidClientCode.Desktop]: "Desktop",
|
|
272
273
|
[CloidClientCode.API]: "API",
|
|
274
|
+
[CloidClientCode.Stream]: "Stream",
|
|
273
275
|
};
|
|
274
276
|
|
|
275
277
|
export function getClientCodeNameById(id: number): string {
|
|
@@ -282,6 +284,7 @@ export const WidgetType = {
|
|
|
282
284
|
SidePanel: 1,
|
|
283
285
|
Widget: 2,
|
|
284
286
|
FloatingWidget: 3,
|
|
287
|
+
Stream: 4,
|
|
285
288
|
} as const;
|
|
286
289
|
type WidgetType = keyof typeof WidgetType;
|
|
287
290
|
|
|
@@ -292,6 +295,7 @@ export const WidgetTypeById: Record<number, WidgetType> = {
|
|
|
292
295
|
[WidgetType.SidePanel]: "SidePanel",
|
|
293
296
|
[WidgetType.Widget]: "Widget",
|
|
294
297
|
[WidgetType.FloatingWidget]: "FloatingWidget",
|
|
298
|
+
[WidgetType.Stream]: "Stream",
|
|
295
299
|
};
|
|
296
300
|
|
|
297
301
|
export function getWidgetTypeById(id: number): string {
|
package/lib/hip3/utils.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExchangeClient,
|
|
3
|
+
InfoClient,
|
|
4
|
+
SuccessResponse,
|
|
5
|
+
} from "@nktkas/hyperliquid";
|
|
6
|
+
import {
|
|
7
|
+
signL1Action,
|
|
8
|
+
signUserSignedAction,
|
|
9
|
+
} from "@nktkas/hyperliquid/signing";
|
|
10
|
+
|
|
1
11
|
export function isHip3Symbol(symbol: string) {
|
|
2
12
|
if (!symbol) return false;
|
|
3
13
|
return symbol.includes(":");
|
|
@@ -7,3 +17,82 @@ export function getHip3Dex(symbol: string) {
|
|
|
7
17
|
if (!symbol) return null;
|
|
8
18
|
return symbol.split(":")[0];
|
|
9
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Enable HIP-3 DEX abstraction with the current agent wallet
|
|
23
|
+
* @param client Exchange client with agent wallet
|
|
24
|
+
* @returns Promise with success response
|
|
25
|
+
*/
|
|
26
|
+
export async function enableHip3DexAbstractionWithAgent(
|
|
27
|
+
client: ExchangeClient,
|
|
28
|
+
) {
|
|
29
|
+
const nonce = Date.now();
|
|
30
|
+
const action = {
|
|
31
|
+
type: "agentEnableDexAbstraction",
|
|
32
|
+
};
|
|
33
|
+
const signature = await signL1Action({
|
|
34
|
+
wallet: client.wallet,
|
|
35
|
+
action,
|
|
36
|
+
isTestnet: client.isTestnet,
|
|
37
|
+
nonce,
|
|
38
|
+
});
|
|
39
|
+
return await client.transport.request<SuccessResponse>("exchange", {
|
|
40
|
+
action,
|
|
41
|
+
signature,
|
|
42
|
+
nonce,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const UserDexAbstractionTypes = {
|
|
47
|
+
"HyperliquidTransaction:UserDexAbstraction": [
|
|
48
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
49
|
+
{ name: "user", type: "address" },
|
|
50
|
+
{ name: "enabled", type: "bool" },
|
|
51
|
+
{ name: "nonce", type: "uint64" },
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Set HIP-3 DEX abstraction for a user
|
|
57
|
+
* @param client Exchange client with owner wallet
|
|
58
|
+
* @param enabled Whether to enable HIP-3 DEX abstraction
|
|
59
|
+
* @param user User address
|
|
60
|
+
* @returns Promise with success response
|
|
61
|
+
*/
|
|
62
|
+
export async function setHip3DexAbstraction(
|
|
63
|
+
client: ExchangeClient,
|
|
64
|
+
enabled: boolean,
|
|
65
|
+
user: string,
|
|
66
|
+
) {
|
|
67
|
+
const nonce = Date.now();
|
|
68
|
+
const isTestnet = client.isTestnet;
|
|
69
|
+
|
|
70
|
+
const action = {
|
|
71
|
+
type: "userDexAbstraction",
|
|
72
|
+
hyperliquidChain: isTestnet ? "Testnet" : "Mainnet",
|
|
73
|
+
signatureChainId: isTestnet
|
|
74
|
+
? ("0x66eee" as `0x${string}`)
|
|
75
|
+
: ("0xa4b1" as `0x${string}`),
|
|
76
|
+
user,
|
|
77
|
+
enabled,
|
|
78
|
+
nonce,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const signature = await signUserSignedAction({
|
|
82
|
+
wallet: client.wallet,
|
|
83
|
+
action,
|
|
84
|
+
types: UserDexAbstractionTypes,
|
|
85
|
+
});
|
|
86
|
+
return await client.transport.request<SuccessResponse>("exchange", {
|
|
87
|
+
action,
|
|
88
|
+
signature,
|
|
89
|
+
nonce: action.nonce,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function getHip3DexAbstraction(client: InfoClient, user: string) {
|
|
94
|
+
return await client.transport.request<boolean | null>("info", {
|
|
95
|
+
type: "userDexAbstraction",
|
|
96
|
+
user,
|
|
97
|
+
});
|
|
98
|
+
}
|
package/lib/meta/metadata.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SpotToken,
|
|
8
8
|
} from "@nktkas/hyperliquid";
|
|
9
9
|
import { isHip3Symbol } from "../hip3/utils";
|
|
10
|
-
import { Hex } from "@nktkas/hyperliquid/
|
|
10
|
+
import type { Hex } from "@nktkas/hyperliquid/types";
|
|
11
11
|
|
|
12
12
|
export interface PerpDex {
|
|
13
13
|
/** Short name of the perpetual dex. */
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basedone/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Core utilities for Based One",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
|
+
"react-native": "./dist/index.mjs",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"react-native": "./dist/index.mjs",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
8
16
|
"source": "./index.ts",
|
|
9
17
|
"files": [
|
|
10
18
|
"dist",
|