@gibs/bridge-sdk 1.19.0 → 1.20.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/abis.js +0 -2
- package/dist/bridge-limits.js +0 -38
- package/dist/chain-info.js +0 -116
- package/dist/chain-names.js +0 -151
- package/dist/chains.js +0 -198
- package/dist/cjs/abis.js +0 -2
- package/dist/cjs/bridge-limits.js +0 -38
- package/dist/cjs/chain-info.js +0 -116
- package/dist/cjs/chain-names.js +0 -151
- package/dist/cjs/chains.js +0 -198
- package/dist/cjs/claims.js +0 -60
- package/dist/cjs/config.js +1 -208
- package/dist/cjs/consolidated-quote.js +0 -465
- package/dist/cjs/destination-calldata.js +0 -71
- package/dist/cjs/ecosystems.js +0 -183
- package/dist/cjs/execution.js +0 -92
- package/dist/cjs/fee-type.js +0 -1
- package/dist/cjs/hyperliquid-execution.js +0 -98
- package/dist/cjs/image-links.js +0 -108
- package/dist/cjs/lifi-execution-guard.js +65 -172
- package/dist/cjs/near-intents-conformance.js +0 -110
- package/dist/cjs/near-intents-route.js +0 -149
- package/dist/cjs/near-intents.js +0 -562
- package/dist/cjs/origin-deposit.js +0 -56
- package/dist/cjs/pre-quote.js +0 -80
- package/dist/cjs/prices.js +0 -113
- package/dist/cjs/providers.js +0 -83
- package/dist/cjs/quote-fees.js +0 -80
- package/dist/cjs/referral.js +0 -75
- package/dist/cjs/relay-currencies.js +0 -31
- package/dist/cjs/relay-depository.js +52 -77
- package/dist/cjs/relay-quote.js +0 -394
- package/dist/cjs/route-steps.js +0 -100
- package/dist/cjs/routing/amounts.js +0 -83
- package/dist/cjs/routing/candidate-route.js +0 -73
- package/dist/cjs/routing/candidate.js +0 -46
- package/dist/cjs/routing/carrier-provider-key.js +0 -27
- package/dist/cjs/routing/carriers/omnibridge.js +0 -120
- package/dist/cjs/routing/carriers/pulsex-paths.js +0 -57
- package/dist/cjs/routing/carriers/pulsex-split.js +0 -92
- package/dist/cjs/routing/carriers/pulsex.js +0 -279
- package/dist/cjs/routing/carriers/wrap.js +0 -57
- package/dist/cjs/routing/composed-route-quality.js +0 -95
- package/dist/cjs/routing/entry-chain-anchor.js +0 -27
- package/dist/cjs/routing/format.js +0 -50
- package/dist/cjs/routing/index.js +0 -28
- package/dist/cjs/routing/producers.js +0 -854
- package/dist/cjs/routing/providers.js +0 -27
- package/dist/cjs/routing/search/compose.js +0 -56
- package/dist/cjs/routing/search/graph.js +0 -364
- package/dist/cjs/routing/search/plan-route-data.js +0 -508
- package/dist/cjs/routing/search/score.js +0 -344
- package/dist/cjs/routing/swap-transactions.js +0 -74
- package/dist/cjs/routing/usd-value.js +0 -12
- package/dist/cjs/settings.js +1 -456
- package/dist/cjs/swap-venues.js +0 -17
- package/dist/cjs/ton-connect.js +0 -82
- package/dist/cjs/ton-execution.js +0 -6
- package/dist/cjs/ton.js +0 -42
- package/dist/cjs/tron-execution.js +0 -145
- package/dist/claims.js +0 -60
- package/dist/config.js +1 -211
- package/dist/consolidated-quote.js +0 -465
- package/dist/destination-calldata.js +0 -71
- package/dist/ecosystems.js +0 -183
- package/dist/execution.js +0 -92
- package/dist/fee-type.js +0 -2
- package/dist/hyperliquid-execution.js +0 -98
- package/dist/image-links.js +0 -108
- package/dist/lifi-execution-guard.js +65 -172
- package/dist/near-intents-conformance.js +0 -110
- package/dist/near-intents-route.js +0 -149
- package/dist/near-intents.js +0 -562
- package/dist/origin-deposit.js +0 -56
- package/dist/pre-quote.js +0 -80
- package/dist/prices.js +0 -113
- package/dist/providers.js +0 -83
- package/dist/quote-fees.js +0 -80
- package/dist/referral.js +0 -75
- package/dist/relay-currencies.js +0 -31
- package/dist/relay-depository.js +52 -77
- package/dist/relay-quote.js +0 -394
- package/dist/route-steps.js +0 -100
- package/dist/routing/amounts.js +0 -83
- package/dist/routing/candidate-route.js +0 -73
- package/dist/routing/candidate.js +0 -46
- package/dist/routing/carrier-provider-key.js +0 -27
- package/dist/routing/carriers/omnibridge.js +0 -120
- package/dist/routing/carriers/pulsex-paths.js +0 -57
- package/dist/routing/carriers/pulsex-split.js +0 -92
- package/dist/routing/carriers/pulsex.js +0 -279
- package/dist/routing/carriers/wrap.js +0 -57
- package/dist/routing/composed-route-quality.js +0 -95
- package/dist/routing/entry-chain-anchor.js +0 -27
- package/dist/routing/format.js +0 -50
- package/dist/routing/index.js +0 -28
- package/dist/routing/producers.js +0 -854
- package/dist/routing/providers.js +0 -27
- package/dist/routing/search/compose.js +0 -56
- package/dist/routing/search/graph.js +0 -364
- package/dist/routing/search/plan-route-data.js +0 -508
- package/dist/routing/search/score.js +0 -344
- package/dist/routing/swap-transactions.js +0 -74
- package/dist/routing/usd-value.js +0 -12
- package/dist/settings.js +1 -456
- package/dist/swap-venues.js +0 -17
- package/dist/ton-connect.js +0 -82
- package/dist/ton-execution.js +0 -6
- package/dist/ton.js +0 -42
- package/dist/tron-execution.js +0 -145
- package/package.json +3 -3
package/dist/cjs/config.js
CHANGED
|
@@ -6,37 +6,18 @@ const viem_1 = require("viem");
|
|
|
6
6
|
Chains["PLS"] = "0x171";
|
|
7
7
|
Chains["ETH"] = "0x1";
|
|
8
8
|
Chains["BNB"] = "0x38";
|
|
9
|
-
// testnets
|
|
10
9
|
Chains["SEP"] = "0xaa36a7";
|
|
11
10
|
Chains["V4PLS"] = "0x3af";
|
|
12
|
-
// TBNB = '0x61',
|
|
13
11
|
})(exports.Chains || (exports.Chains = {}));
|
|
14
|
-
/** A map of chain ids to chain keys */
|
|
15
12
|
exports.chainIdToKey = new Map(Object.entries(exports.Chains).map(([key, chain]) => [chain, key]));
|
|
16
|
-
/**
|
|
17
|
-
* Converts a chain id to a chain key
|
|
18
|
-
* @param chainId - the chain id
|
|
19
|
-
* @returns the chain key
|
|
20
|
-
*/
|
|
21
13
|
const toChain = (chainId) => `0x${Number(chainId).toString(16)}`;
|
|
22
14
|
exports.toChain = toChain;
|
|
23
|
-
/**
|
|
24
|
-
* Converts a chain id to a chain key
|
|
25
|
-
* @param chainId - the chain id
|
|
26
|
-
* @returns the chain key
|
|
27
|
-
*/
|
|
28
15
|
const toChainKey = (chainId) => exports.chainIdToKey.get((0, exports.toChain)(chainId));
|
|
29
16
|
exports.toChainKey = toChainKey;
|
|
30
|
-
// /** The provider of an omnibridge */
|
|
31
|
-
// export enum Provider {
|
|
32
|
-
// PULSECHAIN = 'pulsechain',
|
|
33
|
-
// TOKENSEX = 'tokensex',
|
|
34
|
-
// }
|
|
35
17
|
exports.Providers = {
|
|
36
18
|
PULSECHAIN: 'pulsechain',
|
|
37
19
|
TOKENSEX: 'tokensex',
|
|
38
20
|
};
|
|
39
|
-
/** A map of chains to native asset out addresses */
|
|
40
21
|
exports.nativeAssetOut = {
|
|
41
22
|
[exports.Chains.ETH]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
42
23
|
[exports.Chains.BNB]: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
@@ -44,40 +25,15 @@ exports.nativeAssetOut = {
|
|
|
44
25
|
[exports.Chains.SEP]: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
|
|
45
26
|
[exports.Chains.V4PLS]: '0x70499adEBB11Efd915E3b69E700c331778628707',
|
|
46
27
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Four PulseChain mainnet tokens that no other constant in this package
|
|
49
|
-
* names. The PulseX carrier routes swaps through them
|
|
50
|
-
* (`routing/carriers/pulsex-paths.ts`), and the interface builds its
|
|
51
|
-
* PulseChain hub nodes from the two stablecoins.
|
|
52
|
-
*
|
|
53
|
-
* Each address was already in the repository before it moved here: USDC and
|
|
54
|
-
* USDT from the interface's `HUB_STABLECOIN_ADDRESSES`
|
|
55
|
-
* (`packages/ui/src/lib/state/useRouteSearch.ts`), PLSX and HEX from
|
|
56
|
-
* `scripts/route-parity-corpus.ts`. Each one was read on chain again on
|
|
57
|
-
* 2026-10-06 (`symbol()`, `decimals()`): PLSX 18, HEX 8, USDC 6, USDT 6.
|
|
58
|
-
* `getAddress` checksums them at load, so a mistyped character fails the
|
|
59
|
-
* build rather than silently matching nothing.
|
|
60
|
-
*/
|
|
61
28
|
exports.pulsechainTokenAddresses = Object.freeze({
|
|
62
|
-
/** PulseX, the exchange's own token. */
|
|
63
29
|
PLSX: (0, viem_1.getAddress)('0x95b303987a60c71504d99aa1b13b4da07b0790ab'),
|
|
64
|
-
/** HEX. */
|
|
65
30
|
HEX: (0, viem_1.getAddress)('0x2b591e99afe9f32eaa6214f7b7629768c40eeb39'),
|
|
66
|
-
/** USD Coin, bridged from Ethereum. */
|
|
67
31
|
USDC: (0, viem_1.getAddress)('0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07'),
|
|
68
|
-
/** Tether USD, bridged from Ethereum. */
|
|
69
32
|
USDT: (0, viem_1.getAddress)('0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f'),
|
|
70
33
|
});
|
|
71
|
-
/** A map of chains to deprecated native asset out addresses */
|
|
72
34
|
exports.deprecatedNativeAssetOut = {
|
|
73
35
|
[exports.Chains.PLS]: new Set(['0x97Ac4a2439A47c07ad535bb1188c989dae755341']),
|
|
74
36
|
};
|
|
75
|
-
/**
|
|
76
|
-
* Routers on chains where this package knows the router but has not verified
|
|
77
|
-
* a factory, so no {@link SwapVenue} can be built for them. They stay in
|
|
78
|
-
* {@link uniV2Routers} for the native-price reads (`chain-info.ts`,
|
|
79
|
-
* `readAmountOut`) that need only a router.
|
|
80
|
-
*/
|
|
81
37
|
const routersWithoutVenue = {
|
|
82
38
|
[exports.Chains.ETH]: ['0x7a250d5630b4cf539739df2c5dacb4c659f2488d'],
|
|
83
39
|
[exports.Chains.BNB]: ['0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F'],
|
|
@@ -87,15 +43,6 @@ const routersWithoutVenue = {
|
|
|
87
43
|
'0x636f6407B90661b73b1C0F7e24F4C79f624d0738',
|
|
88
44
|
],
|
|
89
45
|
};
|
|
90
|
-
/**
|
|
91
|
-
* The swap venues the package ships with: PulseX V1 then V2 on PulseChain.
|
|
92
|
-
* Frozen. A caller who wants other routers passes its own
|
|
93
|
-
* {@link SwapVenues} (see `resolveSwapVenues`); this table is never mutated.
|
|
94
|
-
*
|
|
95
|
-
* Each factory is the router's own `router.factory()` read on chain — see
|
|
96
|
-
* {@link uniV2Factories}'s doc. The fee is 29 basis points for both
|
|
97
|
-
* deployments (measured, same doc).
|
|
98
|
-
*/
|
|
99
46
|
exports.defaultSwapVenues = Object.freeze({
|
|
100
47
|
[Number(exports.Chains.PLS)]: Object.freeze([
|
|
101
48
|
Object.freeze({
|
|
@@ -116,43 +63,12 @@ exports.defaultSwapVenues = Object.freeze({
|
|
|
116
63
|
}),
|
|
117
64
|
]),
|
|
118
65
|
});
|
|
119
|
-
/** One chain's routers: its default venues' routers, else the router-only entries. */
|
|
120
66
|
const defaultRoutersFor = (chain) => exports.defaultSwapVenues[Number(chain)]?.map((venue) => venue.router) ?? routersWithoutVenue[chain] ?? [];
|
|
121
|
-
/**
|
|
122
|
-
* A map of chains to uni v2 router addresses. Frozen. PulseChain's entries
|
|
123
|
-
* derive from {@link defaultSwapVenues}, so the two cannot drift. Kept for
|
|
124
|
-
* compatibility; to swap on other routers pass `swapVenues` instead.
|
|
125
|
-
*/
|
|
126
67
|
exports.uniV2Routers = Object.freeze(Object.fromEntries(Object.values(exports.Chains).map((chain) => [chain, Object.freeze([...defaultRoutersFor(chain)])])));
|
|
127
|
-
/**
|
|
128
|
-
* Each {@link uniV2Routers} entry's OWN factory address, same index, same
|
|
129
|
-
* chain — `router.factory()` read live from `one.valve.city` on 2026-09-24.
|
|
130
|
-
* Only PulseChain mainnet is filled: PulseX carries funds nowhere else
|
|
131
|
-
* (`routing/carriers/pulsex.ts`'s own `pulseXCarries`), so no other chain's
|
|
132
|
-
* factory has ever been needed or verified.
|
|
133
|
-
*
|
|
134
|
-
* MEASURED, NOT ASSUMED (owner Rule 13). Reading each factory's `getPair`
|
|
135
|
-
* and the resulting pool's `getReserves`, then recomputing `getAmountsOut`
|
|
136
|
-
* from the standard constant-product formula, showed the SAME fee ratio for
|
|
137
|
-
* both — `9971/10000` (0.29%) — to the base unit, on both a one-hop and a
|
|
138
|
-
* two-hop path. "V1 and V2 differ" was the assumption going in; measurement
|
|
139
|
-
* said otherwise, so `routing/carriers/pulsex.ts`'s `exact` uses one shared
|
|
140
|
-
* fee constant rather than two.
|
|
141
|
-
*
|
|
142
|
-
* `0x1715a3E4A142d8b698131108995174F37aEBA10D` (the V1 factory, index 0) is
|
|
143
|
-
* NOT a copy-paste of the omnibridge's Ethereum mediator address from
|
|
144
|
-
* `pathways` above — it is the same string on a DIFFERENT chain (PulseChain,
|
|
145
|
-
* not Ethereum), confirmed by reading it fresh from `one.valve.city/…/evm/369`.
|
|
146
|
-
* Two unrelated contracts landing on the same address on two different
|
|
147
|
-
* chains is possible (a shared deployer at a matching nonce, or a CREATE2
|
|
148
|
-
* salt collision) and worth this note so a future reader does not assume a
|
|
149
|
-
* transcription error and "fix" it back to something wrong.
|
|
150
|
-
*/
|
|
151
68
|
exports.uniV2Factories = Object.freeze(Object.fromEntries(Object.values(exports.Chains).map((chain) => [
|
|
152
69
|
chain,
|
|
153
70
|
Object.freeze((exports.defaultSwapVenues[Number(chain)] ?? []).map((venue) => venue.factory)),
|
|
154
71
|
])));
|
|
155
|
-
/** A map of chains to native token symbols */
|
|
156
72
|
exports.nativeTokenSymbol = {
|
|
157
73
|
[exports.Chains.PLS]: 'PLS',
|
|
158
74
|
[exports.Chains.V4PLS]: 'V4PLS',
|
|
@@ -160,7 +76,6 @@ exports.nativeTokenSymbol = {
|
|
|
160
76
|
[exports.Chains.SEP]: 'sepETH',
|
|
161
77
|
[exports.Chains.BNB]: 'BNB',
|
|
162
78
|
};
|
|
163
|
-
/** A map of chains to native token names */
|
|
164
79
|
exports.nativeTokenName = {
|
|
165
80
|
[exports.Chains.PLS]: 'Pulse',
|
|
166
81
|
[exports.Chains.V4PLS]: 'V4 Pulse',
|
|
@@ -168,7 +83,6 @@ exports.nativeTokenName = {
|
|
|
168
83
|
[exports.Chains.SEP]: 'Sepolia Ether',
|
|
169
84
|
[exports.Chains.BNB]: 'BNB',
|
|
170
85
|
};
|
|
171
|
-
/** The settings for the pulsechain pls eth pathway */
|
|
172
86
|
const pulsechainPLSETHSettings = {
|
|
173
87
|
from: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
|
|
174
88
|
to: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
|
|
@@ -188,7 +102,6 @@ exports.pathways = {
|
|
|
188
102
|
feeManager: 'from',
|
|
189
103
|
toHome: false,
|
|
190
104
|
requiresDelivery: true,
|
|
191
|
-
// weth from ethereum on pulsechain
|
|
192
105
|
bridgedNativeAssetOut: '0x02DcdD04e3F455D838cd1249292C58f3B79e3C3C',
|
|
193
106
|
settingOverrides: {
|
|
194
107
|
[viem_1.zeroAddress]: pulsechainPLSETHSettings,
|
|
@@ -207,7 +120,6 @@ exports.pathways = {
|
|
|
207
120
|
usesExtraParam: false,
|
|
208
121
|
toHome: true,
|
|
209
122
|
requiresDelivery: false,
|
|
210
|
-
// wpls from pulsechain on ethereum
|
|
211
123
|
bridgedNativeAssetOut: '0xA882606494D86804B5514E07e6Bd2D6a6eE6d68A',
|
|
212
124
|
settingOverrides: {
|
|
213
125
|
[(0, viem_1.getAddress)('0xa882606494d86804b5514e07e6bd2d6a6ee6d68a')]: {
|
|
@@ -232,7 +144,6 @@ exports.pathways = {
|
|
|
232
144
|
usesExtraParam: true,
|
|
233
145
|
toHome: false,
|
|
234
146
|
requiresDelivery: true,
|
|
235
|
-
// wbnb from bsc on pulsechain (tokensex)
|
|
236
147
|
bridgedNativeAssetOut: '0x518076CCE3729eF1a3877EA3647a26e278e764FE',
|
|
237
148
|
},
|
|
238
149
|
},
|
|
@@ -247,36 +158,13 @@ exports.pathways = {
|
|
|
247
158
|
usesExtraParam: true,
|
|
248
159
|
toHome: true,
|
|
249
160
|
requiresDelivery: false,
|
|
250
|
-
// wpls from pulsechain on bsc (tokensex)
|
|
251
161
|
bridgedNativeAssetOut: '0xF6088134D28eeBEF7128BA41FaDb2FCA0666c64C',
|
|
252
162
|
},
|
|
253
163
|
},
|
|
254
164
|
},
|
|
255
165
|
};
|
|
256
166
|
exports.testnetPathways = {
|
|
257
|
-
[exports.Providers.TOKENSEX]: {
|
|
258
|
-
// plsv4 to bnb home omnibridge: 0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C
|
|
259
|
-
// [Chains.BNB]: {
|
|
260
|
-
// [Chains.V4PLS]: {
|
|
261
|
-
// from: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
|
|
262
|
-
// to: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
|
|
263
|
-
// usesExtraParam: false,
|
|
264
|
-
// requiresDelivery: false,
|
|
265
|
-
// toHome: true,
|
|
266
|
-
// feeManager: 'to',
|
|
267
|
-
// defaultAssetIn: {
|
|
268
|
-
// chainId: 56,
|
|
269
|
-
// address: nativeAssetOut[Chains.TBNB],
|
|
270
|
-
// },
|
|
271
|
-
// },
|
|
272
|
-
// },
|
|
273
|
-
// [Chains.V4PLS]: {
|
|
274
|
-
// [Chains.BNB]: {
|
|
275
|
-
// from: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
|
|
276
|
-
// to: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
|
|
277
|
-
// },
|
|
278
|
-
// },
|
|
279
|
-
},
|
|
167
|
+
[exports.Providers.TOKENSEX]: {},
|
|
280
168
|
[exports.Providers.PULSECHAIN]: {
|
|
281
169
|
[exports.Chains.V4PLS]: {
|
|
282
170
|
[exports.Chains.SEP]: {
|
|
@@ -308,49 +196,24 @@ exports.testnetPathways = {
|
|
|
308
196
|
},
|
|
309
197
|
},
|
|
310
198
|
};
|
|
311
|
-
/** The mainnet bridge keys */
|
|
312
199
|
const mainnetBridgeKeys = [
|
|
313
200
|
[exports.Providers.PULSECHAIN, exports.Chains.PLS, exports.Chains.ETH],
|
|
314
201
|
[exports.Providers.PULSECHAIN, exports.Chains.ETH, exports.Chains.PLS],
|
|
315
202
|
[exports.Providers.TOKENSEX, exports.Chains.PLS, exports.Chains.BNB],
|
|
316
203
|
[exports.Providers.TOKENSEX, exports.Chains.BNB, exports.Chains.PLS],
|
|
317
204
|
];
|
|
318
|
-
/** The testnet bridge keys */
|
|
319
205
|
const testnetBridgeKeys = [
|
|
320
206
|
[exports.Providers.PULSECHAIN, exports.Chains.SEP, exports.Chains.V4PLS],
|
|
321
207
|
[exports.Providers.PULSECHAIN, exports.Chains.V4PLS, exports.Chains.SEP],
|
|
322
208
|
];
|
|
323
|
-
/** Returns the valid bridge keys for the given is prod */
|
|
324
209
|
const validBridgeKeys = (isProd) => [
|
|
325
210
|
...mainnetBridgeKeys,
|
|
326
211
|
...(isProd ? [] : testnetBridgeKeys),
|
|
327
212
|
];
|
|
328
213
|
exports.validBridgeKeys = validBridgeKeys;
|
|
329
|
-
/** Every chain that appears only on a testnet pathway. */
|
|
330
214
|
const testnetChains = new Set(testnetBridgeKeys.flatMap(([, fromChain, toChain]) => [fromChain, toChain]));
|
|
331
|
-
/**
|
|
332
|
-
* Whether a chain belongs to the testnet pathway map rather than the mainnet one.
|
|
333
|
-
* @param chain - the chain to classify
|
|
334
|
-
* @returns true for Sepolia and PulseChain testnet V4
|
|
335
|
-
*/
|
|
336
215
|
const isTestnetChain = (chain) => testnetChains.has(chain);
|
|
337
216
|
exports.isTestnetChain = isTestnetChain;
|
|
338
|
-
/**
|
|
339
|
-
* Infers the bridge key from the current key, provider, from chain, and to chain.
|
|
340
|
-
*
|
|
341
|
-
* A chain the provider does not serve falls back to the provider's first chain,
|
|
342
|
-
* so a provider switch lands on a real pathway. That fallback never crosses
|
|
343
|
-
* between the testnet and mainnet maps: when testnets are off and a requested
|
|
344
|
-
* chain is a testnet chain, this returns null rather than a mainnet key for a
|
|
345
|
-
* testnet pair.
|
|
346
|
-
*
|
|
347
|
-
* @param options.currentKey - the current bridge key
|
|
348
|
-
* @param options.provider - the provider
|
|
349
|
-
* @param options.fromChain - the from chain (defaults to the current key's)
|
|
350
|
-
* @param options.toChain - the to chain (defaults to the current key's)
|
|
351
|
-
* @param options.isProd - true leaves testnet pathways out (default false: both maps)
|
|
352
|
-
* @returns the inferred bridge key, or null when no pathway can honour the request
|
|
353
|
-
*/
|
|
354
217
|
const inferBridgeKey = ({ currentKey, provider, fromChain, toChain, isProd = false, }) => {
|
|
355
218
|
const [, fromChainKey, toChainKey] = currentKey;
|
|
356
219
|
const from = fromChain ?? fromChainKey;
|
|
@@ -372,40 +235,8 @@ const inferBridgeKey = ({ currentKey, provider, fromChain, toChain, isProd = fal
|
|
|
372
235
|
return [provider, nextFromChain, nextToChain];
|
|
373
236
|
};
|
|
374
237
|
exports.inferBridgeKey = inferBridgeKey;
|
|
375
|
-
/**
|
|
376
|
-
* Returns the pathway for the given bridge key, is prod, and asset in address
|
|
377
|
-
* @param bridgeKey - the bridge key
|
|
378
|
-
* @param isProd - whether to use the production pathway
|
|
379
|
-
* @param assetInAddress - the asset in address
|
|
380
|
-
* @returns the pathway
|
|
381
|
-
*/
|
|
382
|
-
/**
|
|
383
|
-
* The pathway group for one provider on one chain, honouring the testnet map.
|
|
384
|
-
*
|
|
385
|
-
* Exists because {@link pathway} already knew that testnet pathways live in a
|
|
386
|
-
* SECOND map and are only in play off production, while other callers reached
|
|
387
|
-
* straight into `pathways` and therefore could not see a testnet route at all.
|
|
388
|
-
* That is the sort of knowledge that has to live in one place: duplicated, one
|
|
389
|
-
* copy silently lags the other, and the symptom is a thrown "no pathway found"
|
|
390
|
-
* on a route the rest of the application considers perfectly valid.
|
|
391
|
-
*
|
|
392
|
-
* @param provider - the bridge provider
|
|
393
|
-
* @param chain - the chain being bridged FROM
|
|
394
|
-
* @param isProd - whether this is a production build; testnets are off when true
|
|
395
|
-
* @returns the group keyed by destination chain, or undefined when unknown
|
|
396
|
-
*/
|
|
397
238
|
const pathwayGroup = (provider, chain, isProd) => exports.pathways[provider]?.[chain] || (!isProd ? exports.testnetPathways[provider]?.[chain] : undefined);
|
|
398
239
|
exports.pathwayGroup = pathwayGroup;
|
|
399
|
-
/**
|
|
400
|
-
* Reads one pathway out of a provider, chain and chain map.
|
|
401
|
-
*
|
|
402
|
-
* Every level is optional at runtime: the testnet map leaves whole providers
|
|
403
|
-
* out, and a caller can hold a bridge key built from untrusted input.
|
|
404
|
-
*
|
|
405
|
-
* @param config - the pathway map to read
|
|
406
|
-
* @param bridgeKey - the provider, origin chain and destination chain
|
|
407
|
-
* @returns the pathway, or undefined when any level is missing
|
|
408
|
-
*/
|
|
409
240
|
const lookupPathway = (config, [provider, from, to]) => config[provider]?.[from]?.[to];
|
|
410
241
|
const pathway = (bridgeKey, isProd, assetInAddress) => {
|
|
411
242
|
if (!bridgeKey)
|
|
@@ -424,12 +255,6 @@ const pathway = (bridgeKey, isProd, assetInAddress) => {
|
|
|
424
255
|
return pathway;
|
|
425
256
|
};
|
|
426
257
|
exports.pathway = pathway;
|
|
427
|
-
/**
|
|
428
|
-
* Returns the default asset in for the given bridge key and is prod
|
|
429
|
-
* @param bridgeKey - the bridge key
|
|
430
|
-
* @param isProd - whether to use the production pathway
|
|
431
|
-
* @returns the default asset in
|
|
432
|
-
*/
|
|
433
258
|
const defaultAssetIn = ($bridgeKey, isProd) => {
|
|
434
259
|
if (!$bridgeKey)
|
|
435
260
|
return null;
|
|
@@ -438,18 +263,6 @@ const defaultAssetIn = ($bridgeKey, isProd) => {
|
|
|
438
263
|
return defaultAssetIn;
|
|
439
264
|
};
|
|
440
265
|
exports.defaultAssetIn = defaultAssetIn;
|
|
441
|
-
/**
|
|
442
|
-
* Returns whether the given asset is the native asset for the given bridge key.
|
|
443
|
-
*
|
|
444
|
-
* Never throws. A token whose address is not known yet (a {@link TokenOut} for a
|
|
445
|
-
* not-yet-bridged token), an address that is not a valid address, and a bridge
|
|
446
|
-
* key with no pathway each answer false.
|
|
447
|
-
*
|
|
448
|
-
* @param asset - the asset
|
|
449
|
-
* @param bridgeKey - the bridge key
|
|
450
|
-
* @param options - which pathway maps to read; see {@link PathwayLookupOptions}
|
|
451
|
-
* @returns whether the given asset is the native asset for the given bridge key
|
|
452
|
-
*/
|
|
453
266
|
const isNative = (asset, bridgeKey, options = {}) => {
|
|
454
267
|
if (!bridgeKey || !asset?.address || !(0, viem_1.isAddress)(asset.address, { strict: false })) {
|
|
455
268
|
return false;
|
|
@@ -467,17 +280,6 @@ const isNative = (asset, bridgeKey, options = {}) => {
|
|
|
467
280
|
return isGasTokenOrItsWrapper && !asset.name.includes(' from Pulsechain');
|
|
468
281
|
};
|
|
469
282
|
exports.isNative = isNative;
|
|
470
|
-
/**
|
|
471
|
-
* Returns whether the given asset is unwrappable for the given bridge key.
|
|
472
|
-
*
|
|
473
|
-
* Never throws: a missing or malformed address and a bridge key with no
|
|
474
|
-
* pathway each answer false.
|
|
475
|
-
*
|
|
476
|
-
* @param bridgeKey - the bridge key
|
|
477
|
-
* @param assetIn - the asset in
|
|
478
|
-
* @param options - which pathway maps to read; see {@link PathwayLookupOptions}
|
|
479
|
-
* @returns whether the given asset is unwrappable for the given bridge key
|
|
480
|
-
*/
|
|
481
283
|
const isUnwrappable = (bridgeKey, assetIn, options = {}) => {
|
|
482
284
|
if (!bridgeKey || !assetIn?.address || !(0, viem_1.isAddress)(assetIn.address, { strict: false })) {
|
|
483
285
|
return false;
|
|
@@ -489,13 +291,6 @@ const isUnwrappable = (bridgeKey, assetIn, options = {}) => {
|
|
|
489
291
|
return (0, viem_1.isAddressEqual)(path.bridgedNativeAssetOut, assetIn.address);
|
|
490
292
|
};
|
|
491
293
|
exports.isUnwrappable = isUnwrappable;
|
|
492
|
-
/**
|
|
493
|
-
* Returns whether the given asset can be unwrapped for the given bridge key
|
|
494
|
-
* @param bridgeKey - the bridge key
|
|
495
|
-
* @param assetIn - the asset in
|
|
496
|
-
* @param options - which pathway maps to read; see {@link PathwayLookupOptions}
|
|
497
|
-
* @returns boolean
|
|
498
|
-
*/
|
|
499
294
|
const canChangeUnwrap = (bridgeKey, assetIn, options = {}) => {
|
|
500
295
|
return !!assetIn && (0, exports.isUnwrappable)(bridgeKey, assetIn, options);
|
|
501
296
|
};
|
|
@@ -508,7 +303,6 @@ exports.chains = {
|
|
|
508
303
|
sepolia: 11155111,
|
|
509
304
|
};
|
|
510
305
|
exports.chainIds = Object.values(exports.chains);
|
|
511
|
-
/** Start blocks aligned with when bridge validators began operating — canonical reference for all ponder indexers in this monorepo. */
|
|
512
306
|
exports.startBlocks = {
|
|
513
307
|
ethereum: 17_264_119,
|
|
514
308
|
bsc: 28_987_313,
|
|
@@ -516,7 +310,6 @@ exports.startBlocks = {
|
|
|
516
310
|
pulsechainV4: 16_564_233,
|
|
517
311
|
sepolia: 3_331_901,
|
|
518
312
|
};
|
|
519
|
-
// provider -> home -> foreign
|
|
520
313
|
exports.bridgeConfigs = {
|
|
521
314
|
[exports.Providers.PULSECHAIN]: {
|
|
522
315
|
[exports.chains.pulsechain]: {
|