@gibs/bridge-sdk 1.12.0 → 1.13.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.
Files changed (117) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +234 -432
  3. package/dist/abis.d.ts +1 -0
  4. package/dist/bridge-limits.d.ts +103 -0
  5. package/dist/bridge-limits.js +84 -0
  6. package/dist/chain-info.d.ts +169 -0
  7. package/dist/chain-info.js +410 -0
  8. package/dist/chain-names.d.ts +160 -0
  9. package/dist/chain-names.js +200 -0
  10. package/dist/chains.d.ts +65 -0
  11. package/dist/chains.js +284 -0
  12. package/dist/config.d.ts +216 -0
  13. package/dist/config.js +493 -0
  14. package/dist/consolidated-quote.d.ts +554 -0
  15. package/dist/consolidated-quote.js +773 -0
  16. package/dist/destination-calldata.d.ts +118 -0
  17. package/dist/destination-calldata.js +152 -0
  18. package/dist/ecosystems.d.ts +217 -0
  19. package/dist/ecosystems.js +288 -0
  20. package/dist/fee-type.d.ts +10 -0
  21. package/dist/fee-type.js +9 -0
  22. package/dist/hyperliquid-execution.d.ts +152 -0
  23. package/dist/hyperliquid-execution.js +168 -0
  24. package/dist/image-links.d.ts +117 -0
  25. package/dist/image-links.js +142 -0
  26. package/dist/index.d.ts +20 -0
  27. package/dist/index.js +20 -0
  28. package/dist/lifi-execution-guard.d.ts +199 -0
  29. package/dist/lifi-execution-guard.js +400 -0
  30. package/dist/near-intents-conformance.d.ts +85 -0
  31. package/dist/near-intents-conformance.js +329 -0
  32. package/dist/near-intents-route.d.ts +47 -0
  33. package/dist/near-intents-route.js +265 -0
  34. package/dist/near-intents.d.ts +524 -0
  35. package/dist/near-intents.js +1055 -0
  36. package/dist/origin-deposit.d.ts +326 -0
  37. package/dist/origin-deposit.js +68 -0
  38. package/dist/pre-quote.d.ts +198 -0
  39. package/dist/pre-quote.js +175 -0
  40. package/dist/prices.d.ts +107 -0
  41. package/dist/prices.js +162 -0
  42. package/dist/providers.d.ts +221 -0
  43. package/dist/providers.js +157 -0
  44. package/dist/quote-fees.d.ts +102 -0
  45. package/dist/quote-fees.js +195 -0
  46. package/dist/referral.d.ts +77 -0
  47. package/dist/referral.js +72 -0
  48. package/dist/relay-currencies.d.ts +47 -0
  49. package/dist/relay-currencies.js +89 -0
  50. package/dist/relay-quote.d.ts +301 -0
  51. package/dist/relay-quote.js +983 -0
  52. package/dist/route-steps.d.ts +138 -0
  53. package/dist/route-steps.js +305 -0
  54. package/dist/routing/amounts.d.ts +80 -0
  55. package/dist/routing/amounts.js +120 -0
  56. package/dist/routing/candidate-route.d.ts +43 -0
  57. package/dist/routing/candidate-route.js +45 -0
  58. package/dist/routing/candidate.d.ts +237 -0
  59. package/dist/routing/candidate.js +96 -0
  60. package/dist/routing/carriers/ask-answer.d.ts +58 -0
  61. package/dist/routing/carriers/ask-answer.js +1 -0
  62. package/dist/routing/carriers/omnibridge.d.ts +137 -0
  63. package/dist/routing/carriers/omnibridge.js +419 -0
  64. package/dist/routing/carriers/pulsex.d.ts +111 -0
  65. package/dist/routing/carriers/pulsex.js +404 -0
  66. package/dist/routing/carriers/wrap.d.ts +25 -0
  67. package/dist/routing/carriers/wrap.js +115 -0
  68. package/dist/routing/composed-route-quality.d.ts +103 -0
  69. package/dist/routing/composed-route-quality.js +108 -0
  70. package/dist/routing/entry-chain-anchor.d.ts +88 -0
  71. package/dist/routing/entry-chain-anchor.js +55 -0
  72. package/dist/routing/format.d.ts +31 -0
  73. package/dist/routing/format.js +58 -0
  74. package/dist/routing/index.d.ts +34 -0
  75. package/dist/routing/index.js +42 -0
  76. package/dist/routing/producers.d.ts +770 -0
  77. package/dist/routing/producers.js +1564 -0
  78. package/dist/routing/providers.d.ts +26 -0
  79. package/dist/routing/providers.js +38 -0
  80. package/dist/routing/route-data.d.ts +355 -0
  81. package/dist/routing/route-data.js +1 -0
  82. package/dist/routing/search/compose.d.ts +168 -0
  83. package/dist/routing/search/compose.js +98 -0
  84. package/dist/routing/search/graph.d.ts +639 -0
  85. package/dist/routing/search/graph.js +445 -0
  86. package/dist/routing/search/plan-route-data.d.ts +244 -0
  87. package/dist/routing/search/plan-route-data.js +767 -0
  88. package/dist/routing/search/score.d.ts +324 -0
  89. package/dist/routing/search/score.js +400 -0
  90. package/dist/routing/usd-value.d.ts +17 -0
  91. package/dist/routing/usd-value.js +25 -0
  92. package/dist/settings.d.ts +692 -0
  93. package/dist/settings.js +909 -0
  94. package/dist/ton-execution.d.ts +117 -0
  95. package/dist/ton-execution.js +247 -0
  96. package/dist/tron-execution.d.ts +146 -0
  97. package/dist/tron-execution.js +239 -0
  98. package/dist/types.d.ts +51 -0
  99. package/dist/types.js +1 -0
  100. package/package.json +203 -23
  101. package/src/chain-info.test.ts +0 -968
  102. package/src/chain-info.ts +0 -498
  103. package/src/chains.test.ts +0 -123
  104. package/src/chains.ts +0 -88
  105. package/src/config.test.ts +0 -679
  106. package/src/config.ts +0 -500
  107. package/src/fee-type.test.ts +0 -45
  108. package/src/fee-type.ts +0 -14
  109. package/src/image-links.test.ts +0 -160
  110. package/src/image-links.ts +0 -65
  111. package/src/index.ts +0 -8
  112. package/src/settings.test.ts +0 -2754
  113. package/src/settings.ts +0 -875
  114. package/src/types.ts +0 -48
  115. package/tsconfig.json +0 -17
  116. package/vitest.config.ts +0 -13
  117. /package/{src/abis.ts → dist/abis.js} +0 -0
@@ -0,0 +1,216 @@
1
+ import { type Hex } from 'viem';
2
+ import type { BridgeKey, Token, TokenOut } from './types.js';
3
+ /**
4
+ * Add here your chain id as hex, be sure to add your chain in the chainsMetadata object too
5
+ */
6
+ export declare enum Chains {
7
+ PLS = "0x171",
8
+ ETH = "0x1",
9
+ BNB = "0x38",
10
+ SEP = "0xaa36a7",
11
+ V4PLS = "0x3af"
12
+ }
13
+ /** The key of a chain - human readable for query params */
14
+ export type ChainKey = keyof typeof Chains;
15
+ /** A map of chain ids to chain keys */
16
+ export declare const chainIdToKey: Map<Chains, "PLS" | "ETH" | "BNB" | "SEP" | "V4PLS">;
17
+ /**
18
+ * Converts a chain id to a chain key
19
+ * @param chainId - the chain id
20
+ * @returns the chain key
21
+ */
22
+ export declare const toChain: (chainId: number | string) => Chains;
23
+ /**
24
+ * Converts a chain id to a chain key
25
+ * @param chainId - the chain id
26
+ * @returns the chain key
27
+ */
28
+ export declare const toChainKey: (chainId: number | string) => "PLS" | "ETH" | "BNB" | "SEP" | "V4PLS" | undefined;
29
+ export declare const Providers: {
30
+ readonly PULSECHAIN: "pulsechain";
31
+ readonly TOKENSEX: "tokensex";
32
+ };
33
+ export type Provider = (typeof Providers)[keyof typeof Providers];
34
+ /** A map of chains to native asset out addresses */
35
+ export declare const nativeAssetOut: Record<Chains, Hex>;
36
+ /** A map of chains to deprecated native asset out addresses */
37
+ export declare const deprecatedNativeAssetOut: Partial<Record<Chains, Set<Hex>>>;
38
+ /** A map of chains to uni v2 router addresses */
39
+ export declare const uniV2Routers: Record<Chains, Hex[]>;
40
+ /**
41
+ * Each {@link uniV2Routers} entry's OWN factory address, same index, same
42
+ * chain — `router.factory()` read live from `one.valve.city` on 2026-09-24.
43
+ * Only PulseChain mainnet is filled: PulseX carries funds nowhere else
44
+ * (`routing/carriers/pulsex.ts`'s own `pulseXCarries`), so no other chain's
45
+ * factory has ever been needed or verified.
46
+ *
47
+ * MEASURED, NOT ASSUMED (owner Rule 13). Reading each factory's `getPair`
48
+ * and the resulting pool's `getReserves`, then recomputing `getAmountsOut`
49
+ * from the standard constant-product formula, showed the SAME fee ratio for
50
+ * both — `9971/10000` (0.29%) — to the base unit, on both a one-hop and a
51
+ * two-hop path. "V1 and V2 differ" was the assumption going in; measurement
52
+ * said otherwise, so `routing/carriers/pulsex.ts`'s `exact` uses one shared
53
+ * fee constant rather than two.
54
+ *
55
+ * `0x1715a3E4A142d8b698131108995174F37aEBA10D` (the V1 factory, index 0) is
56
+ * NOT a copy-paste of the omnibridge's Ethereum mediator address from
57
+ * `pathways` above — it is the same string on a DIFFERENT chain (PulseChain,
58
+ * not Ethereum), confirmed by reading it fresh from `one.valve.city/…/evm/369`.
59
+ * Two unrelated contracts landing on the same address on two different
60
+ * chains is possible (a shared deployer at a matching nonce, or a CREATE2
61
+ * salt collision) and worth this note so a future reader does not assume a
62
+ * transcription error and "fix" it back to something wrong.
63
+ */
64
+ export declare const uniV2Factories: Record<Chains, Hex[]>;
65
+ /** A map of chains to native token symbols */
66
+ export declare const nativeTokenSymbol: Record<Chains, string>;
67
+ /** A map of chains to native token names */
68
+ export declare const nativeTokenName: Record<Chains, string>;
69
+ /** The pathway of a bridge */
70
+ export type Pathway = {
71
+ from: Hex;
72
+ to: Hex;
73
+ destinationRouter: Hex | null;
74
+ nativeRouter: Hex;
75
+ validator: Hex;
76
+ usesExtraParam: boolean;
77
+ feeManager: 'from' | 'to';
78
+ toHome: boolean;
79
+ requiresDelivery: boolean;
80
+ bridgedNativeAssetOut: Hex;
81
+ settingOverrides?: Record<Hex, Partial<Pathway>>;
82
+ };
83
+ /** A map of providers to pathways */
84
+ export type DeepPathwayConfig = Record<Provider, Partial<Record<Chains, Partial<Record<Chains, Pathway>>>>>;
85
+ export declare const pathways: DeepPathwayConfig;
86
+ export declare const testnetPathways: DeepPathwayConfig;
87
+ /** Returns the valid bridge keys for the given is prod */
88
+ export declare const validBridgeKeys: (isProd: boolean) => BridgeKey[];
89
+ /**
90
+ * Whether a chain belongs to the testnet pathway map rather than the mainnet one.
91
+ * @param chain - the chain to classify
92
+ * @returns true for Sepolia and PulseChain testnet V4
93
+ */
94
+ export declare const isTestnetChain: (chain: Chains) => boolean;
95
+ /**
96
+ * Infers the bridge key from the current key, provider, from chain, and to chain.
97
+ *
98
+ * A chain the provider does not serve falls back to the provider's first chain,
99
+ * so a provider switch lands on a real pathway. That fallback never crosses
100
+ * between the testnet and mainnet maps: when testnets are off and a requested
101
+ * chain is a testnet chain, this returns null rather than a mainnet key for a
102
+ * testnet pair.
103
+ *
104
+ * @param options.currentKey - the current bridge key
105
+ * @param options.provider - the provider
106
+ * @param options.fromChain - the from chain (defaults to the current key's)
107
+ * @param options.toChain - the to chain (defaults to the current key's)
108
+ * @param options.isProd - true leaves testnet pathways out (default false: both maps)
109
+ * @returns the inferred bridge key, or null when no pathway can honour the request
110
+ */
111
+ export declare const inferBridgeKey: ({ currentKey, provider, fromChain, toChain, isProd, }: {
112
+ currentKey: BridgeKey;
113
+ provider: Provider;
114
+ fromChain?: Chains;
115
+ toChain?: Chains;
116
+ isProd?: boolean;
117
+ }) => BridgeKey | null;
118
+ /**
119
+ * Returns the pathway for the given bridge key, is prod, and asset in address
120
+ * @param bridgeKey - the bridge key
121
+ * @param isProd - whether to use the production pathway
122
+ * @param assetInAddress - the asset in address
123
+ * @returns the pathway
124
+ */
125
+ /**
126
+ * The pathway group for one provider on one chain, honouring the testnet map.
127
+ *
128
+ * Exists because {@link pathway} already knew that testnet pathways live in a
129
+ * SECOND map and are only in play off production, while other callers reached
130
+ * straight into `pathways` and therefore could not see a testnet route at all.
131
+ * That is the sort of knowledge that has to live in one place: duplicated, one
132
+ * copy silently lags the other, and the symptom is a thrown "no pathway found"
133
+ * on a route the rest of the application considers perfectly valid.
134
+ *
135
+ * @param provider - the bridge provider
136
+ * @param chain - the chain being bridged FROM
137
+ * @param isProd - whether this is a production build; testnets are off when true
138
+ * @returns the group keyed by destination chain, or undefined when unknown
139
+ */
140
+ export declare const pathwayGroup: (provider: Provider, chain: Chains, isProd: boolean) => Partial<Record<Chains, Pathway>> | undefined;
141
+ export declare const pathway: (bridgeKey: BridgeKey | null, isProd: boolean, assetInAddress?: string | Hex | null | undefined) => Pathway | undefined;
142
+ /**
143
+ * Returns the default asset in for the given bridge key and is prod
144
+ * @param bridgeKey - the bridge key
145
+ * @param isProd - whether to use the production pathway
146
+ * @returns the default asset in
147
+ */
148
+ export declare const defaultAssetIn: ($bridgeKey: BridgeKey | null, isProd: boolean) => `0x${string}` | null | undefined;
149
+ /** Which pathway maps a lookup reads. */
150
+ export type PathwayLookupOptions = {
151
+ /**
152
+ * true reads the mainnet map alone; false (the default) also reads the
153
+ * testnet map, which is what every caller did before this option existed.
154
+ */
155
+ isProd?: boolean;
156
+ };
157
+ /**
158
+ * Returns whether the given asset is the native asset for the given bridge key.
159
+ *
160
+ * Never throws. A token whose address is not known yet (a {@link TokenOut} for a
161
+ * not-yet-bridged token), an address that is not a valid address, and a bridge
162
+ * key with no pathway each answer false.
163
+ *
164
+ * @param asset - the asset
165
+ * @param bridgeKey - the bridge key
166
+ * @param options - which pathway maps to read; see {@link PathwayLookupOptions}
167
+ * @returns whether the given asset is the native asset for the given bridge key
168
+ */
169
+ export declare const isNative: (asset: Token | TokenOut | null, bridgeKey: BridgeKey | null, options?: PathwayLookupOptions) => boolean;
170
+ /**
171
+ * Returns whether the given asset is unwrappable for the given bridge key.
172
+ *
173
+ * Never throws: a missing or malformed address and a bridge key with no
174
+ * pathway each answer false.
175
+ *
176
+ * @param bridgeKey - the bridge key
177
+ * @param assetIn - the asset in
178
+ * @param options - which pathway maps to read; see {@link PathwayLookupOptions}
179
+ * @returns whether the given asset is unwrappable for the given bridge key
180
+ */
181
+ export declare const isUnwrappable: (bridgeKey: BridgeKey | null, assetIn: {
182
+ address: string | null;
183
+ } | null, options?: PathwayLookupOptions) => boolean;
184
+ /**
185
+ * Returns whether the given asset can be unwrapped for the given bridge key
186
+ * @param bridgeKey - the bridge key
187
+ * @param assetIn - the asset in
188
+ * @param options - which pathway maps to read; see {@link PathwayLookupOptions}
189
+ * @returns boolean
190
+ */
191
+ export declare const canChangeUnwrap: (bridgeKey: BridgeKey, assetIn: Token | null, options?: PathwayLookupOptions) => boolean;
192
+ export declare const chains: {
193
+ readonly ethereum: 1;
194
+ readonly bsc: 56;
195
+ readonly pulsechain: 369;
196
+ readonly pulsechainV4: 943;
197
+ readonly sepolia: 11155111;
198
+ };
199
+ export declare const chainIds: (1 | 56 | 369 | 943 | 11155111)[];
200
+ /** Start blocks aligned with when bridge validators began operating — canonical reference for all ponder indexers in this monorepo. */
201
+ export declare const startBlocks: Record<keyof typeof chains, number>;
202
+ export type ChainId = (typeof chainIds)[number];
203
+ export type Side = 'home' | 'foreign';
204
+ export type MinimalKey = `${ChainId}-${Hex}`;
205
+ export type PathwayInfo = {
206
+ pair: string;
207
+ key: string;
208
+ home: Hex;
209
+ foreign: Hex;
210
+ };
211
+ export type ProviderHomeChainEntry = Partial<Record<ChainId, PathwayInfo[]>>;
212
+ export type ProviderEntries = Partial<Record<ChainId, ProviderHomeChainEntry>>;
213
+ export type BridgeConfig = Record<Provider, ProviderEntries>;
214
+ export declare const bridgeConfigs: BridgeConfig;
215
+ export declare const HOME_TO_FOREIGN_FEE: `0x${string}`;
216
+ export declare const FOREIGN_TO_HOME_FEE: `0x${string}`;