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