@gibs/bridge-sdk 1.10.1 → 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 (122) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +234 -432
  3. package/dist/abis.d.ts +1 -0
  4. package/dist/abis.js +3 -0
  5. package/dist/bridge-limits.d.ts +103 -0
  6. package/dist/bridge-limits.js +84 -0
  7. package/dist/{src/chain-info.d.ts → chain-info.d.ts} +66 -27
  8. package/dist/{src/chain-info.js → chain-info.js} +106 -46
  9. package/dist/chain-names.d.ts +160 -0
  10. package/dist/chain-names.js +200 -0
  11. package/dist/chains.d.ts +65 -0
  12. package/dist/chains.js +284 -0
  13. package/dist/config.d.ts +216 -0
  14. package/dist/{src/config.js → config.js} +151 -44
  15. package/dist/consolidated-quote.d.ts +554 -0
  16. package/dist/consolidated-quote.js +773 -0
  17. package/dist/destination-calldata.d.ts +118 -0
  18. package/dist/destination-calldata.js +152 -0
  19. package/dist/ecosystems.d.ts +217 -0
  20. package/dist/ecosystems.js +288 -0
  21. package/dist/hyperliquid-execution.d.ts +152 -0
  22. package/dist/hyperliquid-execution.js +168 -0
  23. package/dist/image-links.d.ts +117 -0
  24. package/dist/image-links.js +142 -0
  25. package/dist/index.d.ts +20 -0
  26. package/dist/index.js +20 -0
  27. package/dist/lifi-execution-guard.d.ts +199 -0
  28. package/dist/lifi-execution-guard.js +400 -0
  29. package/dist/near-intents-conformance.d.ts +85 -0
  30. package/dist/near-intents-conformance.js +329 -0
  31. package/dist/near-intents-route.d.ts +47 -0
  32. package/dist/near-intents-route.js +265 -0
  33. package/dist/near-intents.d.ts +524 -0
  34. package/dist/near-intents.js +1055 -0
  35. package/dist/origin-deposit.d.ts +326 -0
  36. package/dist/origin-deposit.js +68 -0
  37. package/dist/pre-quote.d.ts +198 -0
  38. package/dist/pre-quote.js +175 -0
  39. package/dist/prices.d.ts +107 -0
  40. package/dist/prices.js +162 -0
  41. package/dist/providers.d.ts +221 -0
  42. package/dist/providers.js +157 -0
  43. package/dist/quote-fees.d.ts +102 -0
  44. package/dist/quote-fees.js +195 -0
  45. package/dist/referral.d.ts +77 -0
  46. package/dist/referral.js +72 -0
  47. package/dist/relay-currencies.d.ts +47 -0
  48. package/dist/relay-currencies.js +89 -0
  49. package/dist/relay-quote.d.ts +301 -0
  50. package/dist/relay-quote.js +983 -0
  51. package/dist/route-steps.d.ts +138 -0
  52. package/dist/route-steps.js +305 -0
  53. package/dist/routing/amounts.d.ts +80 -0
  54. package/dist/routing/amounts.js +120 -0
  55. package/dist/routing/candidate-route.d.ts +43 -0
  56. package/dist/routing/candidate-route.js +45 -0
  57. package/dist/routing/candidate.d.ts +237 -0
  58. package/dist/routing/candidate.js +96 -0
  59. package/dist/routing/carriers/ask-answer.d.ts +58 -0
  60. package/dist/routing/carriers/omnibridge.d.ts +137 -0
  61. package/dist/routing/carriers/omnibridge.js +419 -0
  62. package/dist/routing/carriers/pulsex.d.ts +111 -0
  63. package/dist/routing/carriers/pulsex.js +404 -0
  64. package/dist/routing/carriers/wrap.d.ts +25 -0
  65. package/dist/routing/carriers/wrap.js +115 -0
  66. package/dist/routing/composed-route-quality.d.ts +103 -0
  67. package/dist/routing/composed-route-quality.js +108 -0
  68. package/dist/routing/entry-chain-anchor.d.ts +88 -0
  69. package/dist/routing/entry-chain-anchor.js +55 -0
  70. package/dist/routing/format.d.ts +31 -0
  71. package/dist/routing/format.js +58 -0
  72. package/dist/routing/index.d.ts +34 -0
  73. package/dist/routing/index.js +42 -0
  74. package/dist/routing/producers.d.ts +770 -0
  75. package/dist/routing/producers.js +1564 -0
  76. package/dist/routing/providers.d.ts +26 -0
  77. package/dist/routing/providers.js +38 -0
  78. package/dist/routing/route-data.d.ts +355 -0
  79. package/dist/routing/route-data.js +1 -0
  80. package/dist/routing/search/compose.d.ts +168 -0
  81. package/dist/routing/search/compose.js +98 -0
  82. package/dist/routing/search/graph.d.ts +639 -0
  83. package/dist/routing/search/graph.js +445 -0
  84. package/dist/routing/search/plan-route-data.d.ts +244 -0
  85. package/dist/routing/search/plan-route-data.js +767 -0
  86. package/dist/routing/search/score.d.ts +324 -0
  87. package/dist/routing/search/score.js +400 -0
  88. package/dist/routing/usd-value.d.ts +17 -0
  89. package/dist/routing/usd-value.js +25 -0
  90. package/dist/settings.d.ts +692 -0
  91. package/dist/{src/settings.js → settings.js} +338 -71
  92. package/dist/ton-execution.d.ts +117 -0
  93. package/dist/ton-execution.js +247 -0
  94. package/dist/tron-execution.d.ts +146 -0
  95. package/dist/tron-execution.js +239 -0
  96. package/dist/{src/types.d.ts → types.d.ts} +8 -1
  97. package/dist/types.js +1 -0
  98. package/package.json +210 -23
  99. package/dist/src/abis.d.ts +0 -384
  100. package/dist/src/abis.js +0 -68
  101. package/dist/src/chains.d.ts +0 -6
  102. package/dist/src/chains.js +0 -86
  103. package/dist/src/config.d.ts +0 -136
  104. package/dist/src/image-links.d.ts +0 -41
  105. package/dist/src/image-links.js +0 -45
  106. package/dist/src/index.d.ts +0 -8
  107. package/dist/src/index.js +0 -8
  108. package/dist/src/settings.d.ts +0 -357
  109. package/dist/tsconfig.tsbuildinfo +0 -1
  110. package/src/abis.ts +0 -70
  111. package/src/chain-info.ts +0 -464
  112. package/src/chains.ts +0 -88
  113. package/src/config.ts +0 -480
  114. package/src/fee-type.ts +0 -14
  115. package/src/image-links.ts +0 -61
  116. package/src/index.ts +0 -8
  117. package/src/settings.ts +0 -898
  118. package/src/types.ts +0 -48
  119. package/tsconfig.json +0 -16
  120. /package/dist/{src/fee-type.d.ts → fee-type.d.ts} +0 -0
  121. /package/dist/{src/fee-type.js → fee-type.js} +0 -0
  122. /package/dist/{src/types.js → routing/carriers/ask-answer.js} +0 -0
package/src/config.ts DELETED
@@ -1,480 +0,0 @@
1
- import { getAddress, keccak256, stringToHex, zeroAddress, type Hex } from "viem";
2
- import _ from 'lodash'
3
- import type { BridgeKey, Token, TokenOut } from "./types.js";
4
-
5
- /**
6
- * Add here your chain id as hex, be sure to add your chain in the chainsMetadata object too
7
- */
8
- export enum Chains {
9
- PLS = '0x171',
10
- ETH = '0x1',
11
- BNB = '0x38',
12
- // testnets
13
- SEP = '0xaa36a7',
14
- V4PLS = '0x3af',
15
- // TBNB = '0x61',
16
- }
17
-
18
- /** The key of a chain - human readable for query params */
19
- export type ChainKey = keyof typeof Chains
20
-
21
- /** A map of chain ids to chain keys */
22
- export const chainIdToKey = new Map<Chains, ChainKey>(
23
- Object.entries(Chains).map(([key, chain]) => [chain, key] as [Chains, ChainKey]),
24
- )
25
-
26
- /**
27
- * Converts a chain id to a chain key
28
- * @param chainId - the chain id
29
- * @returns the chain key
30
- */
31
- export const toChain = (chainId: number | string) => `0x${Number(chainId).toString(16)}` as Chains
32
-
33
- /**
34
- * Converts a chain id to a chain key
35
- * @param chainId - the chain id
36
- * @returns the chain key
37
- */
38
- export const toChainKey = (chainId: number | string) => chainIdToKey.get(toChain(chainId))
39
-
40
- // /** The provider of an omnibridge */
41
- // export enum Provider {
42
- // PULSECHAIN = 'pulsechain',
43
- // TOKENSEX = 'tokensex',
44
- // }
45
-
46
-
47
- export const Providers = {
48
- PULSECHAIN: 'pulsechain',
49
- TOKENSEX: 'tokensex',
50
- } as const
51
-
52
- export type Provider = typeof Providers[keyof typeof Providers]
53
-
54
- /** A map of chains to native asset out addresses */
55
- export const nativeAssetOut = {
56
- [Chains.ETH]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
57
- [Chains.BNB]: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
58
- [Chains.PLS]: '0xA1077a294dDE1B09bB078844df40758a5D0f9a27',
59
- [Chains.SEP]: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
60
- [Chains.V4PLS]: '0x70499adEBB11Efd915E3b69E700c331778628707',
61
- } as Record<Chains, Hex>
62
-
63
- /** A map of chains to deprecated native asset out addresses */
64
- export const deprecatedNativeAssetOut = {
65
- [Chains.PLS]: new Set(['0x97Ac4a2439A47c07ad535bb1188c989dae755341']),
66
- } as Partial<Record<Chains, Set<Hex>>>
67
-
68
- /** A map of chains to uni v2 router addresses */
69
- export const uniV2Routers = {
70
- [Chains.PLS]: [
71
- '0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02',
72
- '0x165C3410fC91EF562C50559f7d2289fEbed552d9',
73
- ],
74
- [Chains.ETH]: ['0x7a250d5630b4cf539739df2c5dacb4c659f2488d'],
75
- [Chains.BNB]: ['0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F'],
76
- [Chains.SEP]: ['0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3'],
77
- [Chains.V4PLS]: [
78
- '0xDaE9dd3d1A52CfCe9d5F2fAC7fDe164D500E50f7',
79
- '0x636f6407B90661b73b1C0F7e24F4C79f624d0738',
80
- ],
81
- } as Record<Chains, Hex[]>
82
-
83
- /** A map of chains to native token symbols */
84
- export const nativeTokenSymbol = {
85
- [Chains.PLS]: 'PLS',
86
- [Chains.V4PLS]: 'V4PLS',
87
- [Chains.ETH]: 'ETH',
88
- [Chains.SEP]: 'sepETH',
89
- [Chains.BNB]: 'BNB',
90
- } as Record<Chains, string>
91
-
92
- /** A map of chains to native token names */
93
- export const nativeTokenName = {
94
- [Chains.PLS]: 'Pulse',
95
- [Chains.V4PLS]: 'V4 Pulse',
96
- [Chains.ETH]: 'Ether',
97
- [Chains.SEP]: 'Sepolia Ether',
98
- [Chains.BNB]: 'BNB',
99
- } as Record<Chains, string>
100
-
101
- /** The pathway of a bridge */
102
- export type Pathway = {
103
- from: Hex
104
- to: Hex
105
- destinationRouter: Hex | null
106
- nativeRouter: Hex
107
- validator: Hex
108
- // defaultAssetIn: Token
109
- usesExtraParam: boolean
110
- feeManager: 'from' | 'to'
111
- toHome: boolean
112
- requiresDelivery: boolean
113
- bridgedNativeAssetOut: Hex
114
- settingOverrides?: Record<Hex, Partial<Pathway>>
115
- }
116
-
117
- /** A map of providers to pathways */
118
- export type DeepPathwayConfig = Record<
119
- Provider,
120
- Partial<Record<Chains, Partial<Record<Chains, Pathway>>>>
121
- >
122
-
123
- /** The settings for the pulsechain pls eth pathway */
124
- const pulsechainPLSETHSettings = {
125
- from: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
126
- to: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
127
- destinationRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
128
- nativeRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
129
- }
130
-
131
- export const pathways = {
132
- [Providers.PULSECHAIN]: {
133
- [Chains.PLS]: {
134
- [Chains.ETH]: {
135
- from: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
136
- to: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
137
- destinationRouter: '0x2Ed02372C3efF1F239B22a901ceA8Cf6fbf82d8d',
138
- nativeRouter: '0x612Da68aA7BcA625dD2F27f252cddB573674991A',
139
- validator: '0x5ECfE77502317F3677f23C3b8Ab17929ACE3D74E',
140
- usesExtraParam: false,
141
- feeManager: 'from',
142
- toHome: false,
143
- requiresDelivery: true,
144
- // weth from ethereum on pulsechain
145
- bridgedNativeAssetOut: '0x02DcdD04e3F455D838cd1249292C58f3B79e3C3C',
146
- settingOverrides: {
147
- [zeroAddress]: pulsechainPLSETHSettings,
148
- [getAddress(nativeAssetOut[Chains.PLS])]: pulsechainPLSETHSettings,
149
- },
150
- },
151
- },
152
- [Chains.ETH]: {
153
- [Chains.PLS]: {
154
- from: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
155
- to: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
156
- nativeRouter: '0x2Ed02372C3efF1F239B22a901ceA8Cf6fbf82d8d',
157
- destinationRouter: '0x612Da68aA7BcA625dD2F27f252cddB573674991A',
158
- validator: '0x5ECfE77502317F3677f23C3b8Ab17929ACE3D74E',
159
- feeManager: 'to',
160
- usesExtraParam: false,
161
- toHome: true,
162
- requiresDelivery: false,
163
- // wpls from pulsechain on ethereum
164
- bridgedNativeAssetOut: '0xA882606494D86804B5514E07e6Bd2D6a6eE6d68A',
165
- settingOverrides: {
166
- [getAddress('0xa882606494d86804b5514e07e6bd2d6a6ee6d68a')]: {
167
- from: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
168
- to: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
169
- destinationRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
170
- nativeRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
171
- },
172
- },
173
- },
174
- },
175
- },
176
- [Providers.TOKENSEX]: {
177
- [Chains.PLS]: {
178
- [Chains.BNB]: {
179
- from: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
180
- to: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
181
- destinationRouter: '0x9c50EfD36dF2DBD310fBC981d6D8478cF3484B85',
182
- nativeRouter: '0xB80B80EBB375BD83a9d6c0761b197d16a8670f81',
183
- validator: '0xc3c3d5d3ba946a2eb3906878ebe187418b0b524e',
184
- feeManager: 'from',
185
- usesExtraParam: true,
186
- toHome: false,
187
- requiresDelivery: true,
188
- // wbnb from bsc on pulsechain (tokensex)
189
- bridgedNativeAssetOut: '0x518076CCE3729eF1a3877EA3647a26e278e764FE',
190
- },
191
- },
192
- [Chains.BNB]: {
193
- [Chains.PLS]: {
194
- from: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
195
- to: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
196
- nativeRouter: '0x9c50EfD36dF2DBD310fBC981d6D8478cF3484B85',
197
- destinationRouter: '0xB80B80EBB375BD83a9d6c0761b197d16a8670f81',
198
- validator: '0xc3c3d5d3ba946a2eb3906878ebe187418b0b524e',
199
- feeManager: 'to',
200
- usesExtraParam: true,
201
- toHome: true,
202
- requiresDelivery: false,
203
- // wpls from pulsechain on bsc (tokensex)
204
- bridgedNativeAssetOut: '0xF6088134D28eeBEF7128BA41FaDb2FCA0666c64C',
205
- },
206
- },
207
- },
208
- } as DeepPathwayConfig
209
-
210
- export const testnetPathways = {
211
- [Providers.TOKENSEX]: {
212
- // plsv4 to bnb home omnibridge: 0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C
213
- // [Chains.BNB]: {
214
- // [Chains.V4PLS]: {
215
- // from: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
216
- // to: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
217
- // usesExtraParam: false,
218
- // requiresDelivery: false,
219
- // toHome: true,
220
- // feeManager: 'to',
221
- // defaultAssetIn: {
222
- // chainId: 56,
223
- // address: nativeAssetOut[Chains.TBNB],
224
- // },
225
- // },
226
- // },
227
- // [Chains.V4PLS]: {
228
- // [Chains.BNB]: {
229
- // from: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
230
- // to: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
231
- // },
232
- // },
233
- },
234
- [Providers.PULSECHAIN]: {
235
- [Chains.V4PLS]: {
236
- [Chains.SEP]: {
237
- from: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
238
- to: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
239
- nativeRouter: '0xCA1BDc038909038C4B3cbab0EA0ec3cC2839F106',
240
- destinationRouter: '0xCb4057d7DA4CE521B93b71186DfE11f9FBC3e3b1',
241
- validator: '0xDcd4D88552c86114b2ca029F7F8d4e1a7951d051',
242
- usesExtraParam: false,
243
- requiresDelivery: true,
244
- toHome: false,
245
- feeManager: 'from',
246
- bridgedNativeAssetOut: '0x3677bd78ccf4d299328ecfba61790cf8dbfcf686',
247
- },
248
- },
249
- [Chains.SEP]: {
250
- [Chains.V4PLS]: {
251
- from: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
252
- to: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
253
- nativeRouter: '0xCb4057d7DA4CE521B93b71186DfE11f9FBC3e3b1',
254
- destinationRouter: '0xCA1BDc038909038C4B3cbab0EA0ec3cC2839F106',
255
- validator: '0xDcd4D88552c86114b2ca029F7F8d4e1a7951d051',
256
- usesExtraParam: false,
257
- requiresDelivery: false,
258
- toHome: true,
259
- feeManager: 'to',
260
- bridgedNativeAssetOut: '0x35807560aD0597E23F452cdc82D4Fb0e7E3c6590',
261
- },
262
- },
263
- },
264
- } as DeepPathwayConfig
265
-
266
- /** The mainnet bridge keys */
267
- const mainnetBridgeKeys = [
268
- [Providers.PULSECHAIN, Chains.PLS, Chains.ETH],
269
- [Providers.PULSECHAIN, Chains.ETH, Chains.PLS],
270
- [Providers.TOKENSEX, Chains.PLS, Chains.BNB],
271
- [Providers.TOKENSEX, Chains.BNB, Chains.PLS],
272
- ] as BridgeKey[]
273
-
274
- /** The testnet bridge keys */
275
- const testnetBridgeKeys = [
276
- [Providers.PULSECHAIN, Chains.SEP, Chains.V4PLS],
277
- [Providers.PULSECHAIN, Chains.V4PLS, Chains.SEP],
278
- ] as BridgeKey[]
279
-
280
- /** Returns the valid bridge keys for the given is prod */
281
- export const validBridgeKeys = (isProd: boolean) => [
282
- ...mainnetBridgeKeys,
283
- ...(isProd ? [] : testnetBridgeKeys),
284
- ]
285
-
286
- /**
287
- * Infers the bridge key from the current key, provider, from chain, and to chain
288
- * @param currentKey - the current bridge key
289
- * @param provider - the provider
290
- * @param fromChain - the from chain
291
- * @param toChain - the to chain
292
- * @returns the inferred bridge key
293
- */
294
- export const inferBridgeKey = ({
295
- currentKey,
296
- provider,
297
- fromChain,
298
- toChain,
299
- }: {
300
- currentKey: BridgeKey
301
- provider: Provider
302
- fromChain?: Chains
303
- toChain?: Chains
304
- }) => {
305
- const [, fromChainKey, toChainKey] = currentKey
306
- const from = fromChain ?? fromChainKey
307
- const to = toChain ?? toChainKey
308
- const currentFromChainIsValid = !!_.get(pathways, [provider, from])
309
- const nextFromChain = currentFromChainIsValid
310
- ? from
311
- : (Object.keys(pathways[provider])[0] as Chains)
312
- const currentToChainIsValid = !!_.get(pathways, [provider, nextFromChain, to])
313
- const nextToChain = currentToChainIsValid
314
- ? to
315
- : (Object.keys(pathways[provider]![nextFromChain]!)[0] as Chains)
316
- return [provider, nextFromChain, nextToChain] as BridgeKey
317
- }
318
-
319
- /**
320
- * Returns the pathway for the given bridge key, is prod, and asset in address
321
- * @param bridgeKey - the bridge key
322
- * @param isProd - whether to use the production pathway
323
- * @param assetInAddress - the asset in address
324
- * @returns the pathway
325
- */
326
- export const pathway = (bridgeKey: BridgeKey | null, isProd: boolean, assetInAddress?: string | Hex | null | undefined) => {
327
- if (!bridgeKey) return
328
- let pathway = _.get(pathways, bridgeKey) || (!isProd ? _.get(testnetPathways, bridgeKey) : undefined)
329
- if (assetInAddress) {
330
- const addr = getAddress(assetInAddress)
331
- if (pathway?.settingOverrides?.[addr]) {
332
- pathway = {
333
- ...pathway,
334
- ...pathway.settingOverrides[addr],
335
- }
336
- }
337
- }
338
- return pathway
339
- }
340
-
341
- /**
342
- * Returns the default asset in for the given bridge key and is prod
343
- * @param bridgeKey - the bridge key
344
- * @param isProd - whether to use the production pathway
345
- * @returns the default asset in
346
- */
347
- export const defaultAssetIn = ($bridgeKey: BridgeKey | null, isProd: boolean) => {
348
- if (!$bridgeKey) return null
349
- const conf = pathway($bridgeKey, isProd)
350
- const defaultAssetIn = _.get(conf, ['bridgedNativeAssetOut']) as Hex | undefined
351
- return defaultAssetIn
352
- }
353
-
354
- /**
355
- * Returns whether the given asset is the native asset for the given bridge key
356
- * @param asset - the asset
357
- * @param bridgeKey - the bridge key
358
- * @returns whether the given asset is the native asset for the given bridge key
359
- */
360
- export const isNative = (asset: Token | TokenOut | null, bridgeKey: BridgeKey | null) => {
361
- if (!bridgeKey || !asset) {
362
- return false
363
- }
364
- const path = pathway(bridgeKey, false)
365
- return (
366
- getAddress(asset.address!) === getAddress(path!.bridgedNativeAssetOut!) ||
367
- (asset.address === zeroAddress ||
368
- nativeAssetOut[toChain(asset.chainId)]?.toLowerCase() === asset.address?.toLowerCase()) &&
369
- !asset.name.includes(' from Pulsechain')
370
- )
371
- }
372
-
373
- /**
374
- * Returns whether the given asset is unwrappable for the given bridge key
375
- * @param bridgeKey - the bridge key
376
- * @param assetIn - the asset in
377
- * @returns whether the given asset is unwrappable for the given bridge key
378
- */
379
- export const isUnwrappable = (
380
- bridgeKey: BridgeKey | null,
381
- assetIn: Pick<Token, 'address'> | null,
382
- ) => {
383
- if (!bridgeKey || !assetIn) {
384
- return false
385
- }
386
- const addr = getAddress(assetIn.address)
387
- const path = pathway(bridgeKey, false)
388
- if (!path) return false
389
- return path.bridgedNativeAssetOut === getAddress(addr)
390
- }
391
-
392
- /**
393
- * Returns whether the given asset can be unwrapped for the given bridge key
394
- * @param bridgeKey - the bridge key
395
- * @param assetIn - the asset in
396
- * @returns boolean
397
- */
398
- export const canChangeUnwrap = (bridgeKey: BridgeKey, assetIn: Token | null) => {
399
- return !!assetIn && isUnwrappable(bridgeKey, assetIn)
400
- }
401
-
402
- export const chains = {
403
- ethereum: 1,
404
- bsc: 56,
405
- pulsechain: 369,
406
- pulsechainV4: 943,
407
- sepolia: 11155111,
408
- } as const
409
-
410
- export const chainIds = Object.values(chains)
411
-
412
- export type ChainId = (typeof chainIds)[number]
413
-
414
- export type Side = 'home' | 'foreign'
415
-
416
- export type MinimalKey = `${ChainId}-${Hex}`
417
-
418
- // export const Providers = {
419
- // PULSECHAIN: 'pulsechain',
420
- // TOKENSEX: 'tokensex',
421
- // } as const
422
-
423
- export type PathwayInfo = {
424
- pair: string
425
- key: string
426
- home: Hex
427
- foreign: Hex
428
- }
429
-
430
- export type ProviderHomeChainEntry = Partial<Record<ChainId, PathwayInfo[]>>
431
-
432
- export type ProviderEntries = Partial<Record<ChainId, ProviderHomeChainEntry>>
433
-
434
- export type BridgeConfig = Record<Provider, ProviderEntries>
435
-
436
- // provider -> home -> foreign
437
- export const bridgeConfigs = {
438
- [Providers.PULSECHAIN]: {
439
- [chains.pulsechain]: {
440
- [chains.ethereum]: [{
441
- pair: 'mainnet',
442
- key: 'erc20',
443
- home: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
444
- foreign: '0x1715a3e4a142d8b698131108995174f37aeba10d',
445
- }, {
446
- pair: 'mainnet',
447
- key: 'native',
448
- home: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
449
- foreign: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
450
- }],
451
- },
452
- [chains.pulsechainV4]: {
453
- [chains.sepolia]: [{
454
- pair: 'v4',
455
- key: 'erc20',
456
- home: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
457
- foreign: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
458
- }, {
459
- pair: 'v4',
460
- key: 'native',
461
- home: '0x81c10846F40fA2B173FC47958D0a892529983F50',
462
- foreign: '0x5e238ef968467cf443ef5ecb683b76c5a04a0421',
463
- }],
464
- },
465
- },
466
- [Providers.TOKENSEX]: {
467
- [chains.pulsechain]: {
468
- [chains.bsc]: [{
469
- pair: 'bsctokensex',
470
- key: 'erc20',
471
- home: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
472
- foreign: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
473
- }],
474
- },
475
- },
476
- } as BridgeConfig
477
-
478
-
479
- export const HOME_TO_FOREIGN_FEE = keccak256(stringToHex("homeToForeignFee"))
480
- export const FOREIGN_TO_HOME_FEE = keccak256(stringToHex("foreignToHomeFee"))
package/src/fee-type.ts DELETED
@@ -1,14 +0,0 @@
1
- /** The type of fee to use for the bridge */
2
- export enum FeeType {
3
- PERCENT = '%',
4
- GAS_TIP = 'gas+%',
5
- FIXED = 'fixed',
6
- }
7
-
8
- /** The keys of the fee type */
9
- export type FeeTypeKeys = keyof typeof FeeType
10
-
11
- /** A map of fee type values to keys */
12
- export const feeTypeValToKeyMap = new Map<FeeType, FeeTypeKeys>(
13
- (Object.keys(FeeType) as FeeTypeKeys[]).map((key) => [FeeType[key], key]),
14
- )
@@ -1,61 +0,0 @@
1
- import { getAddress } from 'viem'
2
-
3
- let imageRoot = 'https://gib.show'
4
-
5
- /**
6
- * Sets the image root for the bridge
7
- * @param root - the root
8
- */
9
- export const setImageRoot = (root: string) => {
10
- imageRoot = root
11
- }
12
-
13
- /**
14
- * Returns the image root for the bridge
15
- * @returns the image root
16
- */
17
- export const getImageRoot = () => imageRoot
18
-
19
- /** The minimal token info */
20
- interface MinimalTokenInfo {
21
- chainId: number
22
- address: string
23
- logoURI?: string | null
24
- }
25
-
26
- /**
27
- * Returns the list image for the given path
28
- * @param path - the path
29
- * @returns the list image
30
- */
31
- export const list = (path: string) => {
32
- return `${imageRoot}/list${path}`
33
- }
34
-
35
- /**
36
- * Returns the network image for the given chain id
37
- * @param chainId - the chain id
38
- * @returns the network image
39
- */
40
- export const network = (chainId: number) => {
41
- if (!chainId) {
42
- console.trace('network image')
43
- }
44
- return `${imageRoot}/image/${Number(chainId)}`
45
- }
46
-
47
- /**
48
- * Returns the image url for the given token info
49
- * @param t - the token info
50
- * @returns the image url
51
- */
52
- export const image = (t: MinimalTokenInfo) =>
53
- t.logoURI || `${network(t.chainId)}/${getAddress(t.address)}`
54
-
55
- /**
56
- * Returns a url that will lookup all sources for the given array
57
- * @param sources - the sources
58
- * @returns the images
59
- */
60
- export const images = (sources: string[]) =>
61
- `${imageRoot}/image/?${sources.map((s) => `i=${s}`).join('&')}`
package/src/index.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from './chain-info.js'
2
- export * from './abis.js'
3
- export * from './config.js'
4
- export * from './chains.js'
5
- export * from './types.js'
6
- export * from './image-links.js'
7
- export * from './fee-type.js'
8
- export * from './settings.js'