@hypermid/sdk 1.2.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/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @hypermid/sdk
2
+
3
+ TypeScript / JavaScript SDK for the [HyperMid](https://hypermid.io) Partner
4
+ API — swap, bridge, and on-ramp across 90+ chains (EVM, Solana, Bitcoin,
5
+ Sui, NEAR, Tron, TON, XRP, Doge).
6
+
7
+ ```bash
8
+ npm install @hypermid/sdk
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ No API key required. The SDK works anonymously out of the box at the
14
+ default fee tier — pass an API key only if you're a partner with
15
+ custom fee terms.
16
+
17
+ ```ts
18
+ import { HyperMid } from "@hypermid/sdk";
19
+
20
+ // Anonymous — works immediately, no signup
21
+ const hm = new HyperMid();
22
+
23
+ // Partner with custom fees / discounts
24
+ const hm = new HyperMid({ apiKey: process.env.HYPERMID_API_KEY });
25
+
26
+ // 1. Quote
27
+ const quote = await hm.getQuote({
28
+ fromChain: 1,
29
+ toChain: 8453,
30
+ fromToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
31
+ toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
32
+ fromAmount: "1000000", // 1 USDC (6 decimals)
33
+ fromAddress: "0xYourWallet",
34
+ toAddress: "0xYourWallet",
35
+ });
36
+
37
+ // 2. Execute (returns the on-chain tx to sign + submit)
38
+ const exec = await hm.execute({ quoteId: quote.id });
39
+
40
+ // 3. Status
41
+ const status = await hm.getStatus({ txHash: "0x...", chainId: 1 });
42
+ ```
43
+
44
+ ## Features
45
+
46
+ - `getQuote` / `execute` / `getStatus` — the swap pipeline
47
+ - `getChains` / `getTokens` — supported chains and tokens
48
+ - `getBalances` — multi-ecosystem wallet balances + USD totals
49
+ - `createWebhook` — register webhook endpoints for swap / on-ramp events
50
+ - `registerInboundReceiver` — SuperSwap V2 inbound deposits
51
+ - On-ramp helpers — `getOnrampQuote`, `getOnrampCheckout`, `getOnrampStatus`
52
+
53
+ ## Authentication
54
+
55
+ The API is open by default — every endpoint works without
56
+ authentication, so you can integrate, test, and ship without a signup.
57
+
58
+ An **API key is only needed if you're a partner** with negotiated terms
59
+ (custom fee splits, fee discounts, volume tiers, higher rate limits,
60
+ webhook events scoped to your traffic). When set, the SDK sends it as
61
+ the `X-API-Key` header.
62
+
63
+ Apply for a partner account at [partner.hypermid.io](https://partner.hypermid.io).
64
+
65
+ ## Documentation
66
+
67
+ Full reference: <https://docs.hypermid.io>
68
+
69
+ ## License
70
+
71
+ MIT
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Unified Hypermid Chain Registry
3
+ *
4
+ * Single source of truth for all chain definitions across the Hypermid platform.
5
+ * Maps Hypermid chain slugs to internal numeric IDs, LiFi chain IDs, and
6
+ * Near Intents blockchain strings.
7
+ *
8
+ * Design:
9
+ * - EVM chains keep their standard numeric chain IDs (1, 42161, 8453...)
10
+ * - Non-EVM chains use human-readable string slugs ("solana", "bitcoin", "near")
11
+ * - Both formats are always accepted via resolveChain()
12
+ * - Protocol routing (LiFi vs Near Intents) is handled internally
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { resolveChain, ChainSlug } from "@hypermid/sdk";
17
+ *
18
+ * // Resolve by slug or numeric ID — both work
19
+ * const eth = resolveChain("ethereum"); // { slug: "ethereum", numericId: 1, ... }
20
+ * const arb = resolveChain(42161); // { slug: "arbitrum", numericId: 42161, ... }
21
+ * const sol = resolveChain("solana"); // { slug: "solana", numericId: 1151111081099710, ... }
22
+ * ```
23
+ */
24
+ export type ChainType = "evm" | "svm" | "utxo" | "near" | "ton" | "tvm" | "xrp" | "stellar" | "cardano" | "aptos" | "starknet" | "mvm" | "aleo" | "other";
25
+ export type Provider = "lifi" | "near-intents";
26
+ export type DepositMode = "wallet" | "manual";
27
+ export interface ChainEntry {
28
+ /** Human-readable slug — the Hypermid chain identifier */
29
+ slug: string;
30
+ /** Internal numeric chain ID (EVM chain ID, LiFi ID, or NI range ID) */
31
+ numericId: number;
32
+ /** Display name */
33
+ name: string;
34
+ /** Chain type / ecosystem */
35
+ type: ChainType;
36
+ /** Which routing backends support this chain */
37
+ providers: Provider[];
38
+ /** Chain ID that LiFi expects (undefined if LiFi doesn't support this chain) */
39
+ lifiChainId?: number;
40
+ /** Near Intents blockchain string (undefined if NI doesn't support this chain) */
41
+ niBlockchain?: string;
42
+ /** Default deposit mode */
43
+ depositMode: DepositMode;
44
+ /** Native token info */
45
+ nativeToken: {
46
+ symbol: string;
47
+ name: string;
48
+ decimals: number;
49
+ };
50
+ /** Placeholder address for dry quotes (no real funds sent) */
51
+ dryQuotePlaceholder?: string;
52
+ }
53
+ export declare const CHAIN_REGISTRY: ChainEntry[];
54
+ /**
55
+ * Resolve a chain by slug (string) or numeric ID (number).
56
+ * Returns the ChainEntry or null if not found.
57
+ *
58
+ * @example
59
+ * resolveChain("ethereum") → { slug: "ethereum", numericId: 1, ... }
60
+ * resolveChain(42161) → { slug: "arbitrum", numericId: 42161, ... }
61
+ * resolveChain("solana") → { slug: "solana", numericId: 1151111081099710, ... }
62
+ * resolveChain(1151111081099710) → { slug: "solana", numericId: 1151111081099710, ... }
63
+ */
64
+ export declare function resolveChain(input: string | number): ChainEntry | null;
65
+ /**
66
+ * Convert any chain identifier to the LiFi chain ID.
67
+ * Returns undefined if LiFi doesn't support this chain.
68
+ */
69
+ export declare function toLifiChainId(input: string | number): number | undefined;
70
+ /**
71
+ * Convert any chain identifier to the Near Intents blockchain string.
72
+ * Returns undefined if Near Intents doesn't support this chain.
73
+ */
74
+ export declare function toNIBlockchain(input: string | number): string | undefined;
75
+ /**
76
+ * Convert any chain identifier to the internal numeric ID.
77
+ * This is the canonical numeric ID used internally.
78
+ */
79
+ export declare function toNumericId(input: string | number): number | undefined;
80
+ /**
81
+ * Check if a chain ID belongs to a Near Intents-only chain (900_000_XXX range).
82
+ */
83
+ export declare function isNIOnlyChain(input: string | number): boolean;
84
+ /**
85
+ * Check if a chain supports wallet-connected deposit mode.
86
+ */
87
+ export declare function supportsWalletDeposit(input: string | number): boolean;
88
+ /**
89
+ * Get the dry quote placeholder address for a chain.
90
+ */
91
+ export declare function getDryQuotePlaceholder(input: string | number): string | undefined;
92
+ /**
93
+ * Get all registered chains.
94
+ */
95
+ export declare function getAllChains(): ChainEntry[];
96
+ /**
97
+ * Get chains filtered by provider.
98
+ */
99
+ export declare function getChainsByProvider(provider: Provider): ChainEntry[];
100
+ /**
101
+ * The Near Intents chain ID base constant (900_000_000).
102
+ */
103
+ export declare const NI_CHAIN_BASE = 900000000;
104
+ //# sourceMappingURL=chain-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-registry.d.ts","sourceRoot":"","sources":["../src/chain-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,MAAM,MAAM,SAAS,GACjB,KAAK,GACL,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,KAAK,GACL,MAAM,GACN,OAAO,CAAC;AAEZ,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;AAC/C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,gDAAgD;IAChD,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC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