@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/abis.ts DELETED
@@ -1,70 +0,0 @@
1
- import { parseAbi, parseAbiParameters } from 'viem'
2
-
3
- /** the abi for the input bridge */
4
- export const inputBridge = parseAbi([
5
- 'function minPerTx(address token) external view returns(uint256)',
6
- 'function foreignTokenAddress(address token) external view returns(address)',
7
- 'function homeTokenAddress(address token) external view returns(address)',
8
- 'function bridgedTokenAddress(address token) external view returns(address)',
9
- 'function nativeTokenAddress(address token) external view returns(address)',
10
- 'function feeManager() external view returns(address)',
11
- 'function relayTokensAndCall(address token, address _receiver, uint256 _value, bytes memory _data) external',
12
- 'function relayTokens(address token, address _receiver, uint256 _value) external',
13
- ])
14
- /** the abi for the input bridge with extra input for the sender origin (tokensex) */
15
- export const inputBridgeExtraInput = parseAbi([
16
- 'function relayTokensAndCall(address token, address _receiver, uint256 _value, bytes memory _data, address _senderOrigin) external',
17
- 'function relayTokens(address token, address _receiver, uint256 _value, address _senderOrigin) external',
18
- ])
19
- /** the abi for erc677 tokens */
20
- export const erc677 = parseAbi([
21
- 'function transferAndCall(address, uint256, bytes calldata) external',
22
- ])
23
- /** the abi for erc677 tokens bridge with extra input for the sender origin (tokensex) */
24
- export const erc677ExtraInput = parseAbi([
25
- 'function transferAndCall(address, uint256, bytes calldata, address sender) external',
26
- ])
27
- /** the abi to read data from the output router */
28
- export const outputRouter = parseAbi([
29
- 'function onTokenBridged(address _token, uint256 _value, bytes memory _data) external payable',
30
- 'function WETH() external view returns(address)',
31
- 'function bridge() external view returns(address)',
32
- 'function safeExecuteSignaturesWithAutoGasLimit(address runner,bytes calldata _data,bytes calldata _signatures) external payable',
33
- ])
34
- /** the abi for the output bridge */
35
- export const outputBridge = parseAbi(['function bridgeContract() external view returns(address)'])
36
- /** the abi for the fee manager */
37
- export const feeManager = parseAbi([
38
- 'function HOME_TO_FOREIGN_FEE() public view returns(bytes32)',
39
- 'function FOREIGN_TO_HOME_FEE() public view returns(bytes32)',
40
- 'function getFee(bytes32, address) public view returns(uint256)',
41
- ])
42
- /** the abi for the native router */
43
- export const nativeRouter = parseAbi([
44
- 'function wrapAndRelayTokens(address receiver) external payable',
45
- 'function relayTokensAndCall(address receiver, bytes calldata data) external payable',
46
- ])
47
- /** the abi for the native router with extra input for the sender origin (tokensex) */
48
- export const nativeRouterExtraInput = parseAbi([
49
- 'function wrapAndRelayTokens(address receiver, address sender) external payable',
50
- 'function relayTokensAndCall(address receiver, bytes calldata data, address sender) external payable',
51
- ])
52
- /** the abi for the univ2 router */
53
- export const univ2Router = parseAbi([
54
- 'function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns(uint256[] memory)',
55
- ])
56
- /** the abi for the fee delivery struct */
57
- export const feeDeliveryStruct = parseAbiParameters('(address, uint256, uint256, uint256)')
58
- /** the abi for the relay tokens direct */
59
- export const relayTokensDirect = parseAbi([
60
- 'function safeExecuteSignaturesWithAutoGasLimit(bytes calldata data, bytes calldata signatures) external',
61
- ])
62
- /** the abi for the home amb */
63
- export const homeAmb = parseAbi([
64
- 'function submitSignature(bytes message, bytes signature) external',
65
- ])
66
-
67
- /** the abi for the univ2 pair */
68
- export const pair = parseAbi([
69
- 'function getReserves() view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast)',
70
- ])
package/src/chain-info.ts DELETED
@@ -1,464 +0,0 @@
1
- import { encodeFunctionData, getContract, type Hex, multicall3Abi, type PublicClient, zeroAddress } from "viem"
2
- import { Chains, nativeAssetOut, type Pathway, pathway, toChain, uniV2Routers } from "./config.js"
3
- import type { BridgeKey, Token } from "./types.js"
4
- import _ from "lodash"
5
- import { chainsMetadata } from "./chains.js"
6
- import * as abis from "./abis.js"
7
- import { multicallRead } from "@gibs/common/multicall"
8
-
9
- export type TokenBridgeInfo = {
10
- originationChainId: Chains
11
- assetInAddress: Hex
12
- assetOutAddress: Hex | null
13
- toForeign?: {
14
- home: Hex
15
- foreign: Hex | null
16
- }
17
- toHome?: {
18
- home: Hex | null
19
- foreign: Hex
20
- }
21
- }
22
-
23
- /**
24
- * Returns the bridged token address and native token address
25
- * @param chainId - the chain id being targeted
26
- * @param target - the target
27
- * @param address - the address
28
- * @param client - the client
29
- * @returns the bridged token address and native token address
30
- */
31
- export const links = _.memoize(
32
- async ({ chainId, target, address, client }: { chainId: number; target: Hex; address: Hex, client: PublicClient }) => {
33
- return multicallRead<[Hex, Hex]>({
34
- client,
35
- chain: chainsMetadata[toChain(chainId)],
36
- abi: abis.inputBridge,
37
- target,
38
- calls: [
39
- { functionName: 'bridgedTokenAddress', args: [address] },
40
- { functionName: 'nativeTokenAddress', args: [address] },
41
- ],
42
- })
43
- },
44
- ({ chainId, target, address }) => `${chainId}-${target}-${address}`.toLowerCase(),
45
- )
46
-
47
- /**
48
- * Returns the token bridge info for the given bridge key, asset in, is prod, from chain client, and to chain client
49
- * @param bridgeKey - the bridge key
50
- * @param assetIn - the asset in
51
- * @param isProd - whether to use the production pathway
52
- * @param fromChainClient - the from chain client
53
- * @param toChainClient - the to chain client
54
- * @returns the token bridge info
55
- */
56
- export const tokenBridgeInfo = async ({
57
- bridgeKey,
58
- assetIn,
59
- isProd,
60
- fromChainClient,
61
- toChainClient,
62
- }: {
63
- bridgeKey: BridgeKey,
64
- assetIn: Token | null,
65
- isProd: boolean,
66
- fromChainClient: PublicClient,
67
- toChainClient: PublicClient,
68
- }): Promise<null | TokenBridgeInfo> => {
69
- const bridgePathway = pathway(bridgeKey, isProd, assetIn?.address as Hex | null)
70
- if (!assetIn || !bridgePathway) {
71
- console.log('missing asset in or bridge pathway')
72
- return null
73
- }
74
- const [, fromChain, toChain] = bridgeKey
75
- const assetInAddress =
76
- assetIn.address === zeroAddress ? nativeAssetOut[fromChain] : assetIn.address
77
- const [toMappings, fromMappings] = await Promise.all([
78
- links({
79
- chainId: Number(toChain),
80
- target: bridgePathway.to,
81
- address: assetInAddress as Hex,
82
- client: toChainClient,
83
- }),
84
- links({
85
- chainId: Number(fromChain),
86
- target: bridgePathway.from,
87
- address: assetInAddress as Hex,
88
- client: fromChainClient,
89
- }),
90
- ])
91
- const [toBridged, toNative] = toMappings
92
- if (toBridged !== zeroAddress) {
93
- return {
94
- originationChainId: fromChain,
95
- assetInAddress: assetInAddress as Hex,
96
- assetOutAddress: toBridged,
97
- toHome: {
98
- home: toBridged,
99
- foreign: assetInAddress as Hex,
100
- },
101
- }
102
- }
103
- if (toNative !== zeroAddress) {
104
- return {
105
- originationChainId: toChain,
106
- assetInAddress: assetInAddress as Hex,
107
- assetOutAddress: toNative,
108
- toForeign: {
109
- home: toNative,
110
- foreign: assetInAddress as Hex,
111
- },
112
- }
113
- }
114
- const [fromBridged, fromNative] = fromMappings
115
- if (fromNative !== zeroAddress) {
116
- return {
117
- originationChainId: toChain,
118
- assetInAddress: assetInAddress as Hex,
119
- assetOutAddress: fromNative,
120
- toHome: {
121
- home: assetInAddress as Hex,
122
- foreign: fromNative,
123
- },
124
- }
125
- }
126
- if (fromBridged !== zeroAddress) {
127
- return {
128
- originationChainId: fromChain,
129
- assetInAddress: assetInAddress as Hex,
130
- assetOutAddress: fromBridged,
131
- toForeign: {
132
- foreign: fromBridged,
133
- home: assetInAddress as Hex,
134
- },
135
- }
136
- }
137
- // the token has not been bridged yet
138
- return {
139
- originationChainId: toChain,
140
- assetInAddress: assetInAddress as Hex,
141
- assetOutAddress: null,
142
- ...(bridgePathway.toHome
143
- ? {
144
- toHome: {
145
- foreign: assetInAddress as Hex,
146
- home: null,
147
- },
148
- }
149
- : {
150
- toForeign: {
151
- foreign: null,
152
- home: assetInAddress as Hex,
153
- },
154
- }),
155
- }
156
- }
157
- /** The result of reading the amount out from a router */
158
- export type FetchResult = bigint[] | Hex
159
- /**
160
- * Check the prices that each router offers for the given paths
161
- * @param assetInAddress the address of the asset going into the bridge
162
- * @param oneTokenInt the number of tokens to push into the bridge (before fees)
163
- * @param chain the chain of the asset going into the bridge
164
- * @param bridgeKey the bridge key
165
- * @param blockNumber the block number to use for the price
166
- * @param paths the paths to check
167
- * @returns the prices as bigint for each path, hex whenever the price is not available
168
- */
169
- const readAmountOut = ({
170
- amountIn,
171
- chain,
172
- paths,
173
- client,
174
- uniV2Router,
175
- }: {
176
- amountIn: bigint,
177
- chain: Chains,
178
- paths: Hex[][],
179
- client: PublicClient,
180
- uniV2Router?: Hex,
181
- }): Promise<FetchResult[]> => {
182
- return multicallRead<FetchResult[]>({
183
- chain: chainsMetadata[chain],
184
- client,
185
- abi: abis.univ2Router,
186
- // pulsex router
187
- calls: _.flatMap(uniV2Router ? [uniV2Router] : uniV2Routers[chain], (target) =>
188
- paths.map((path) => ({
189
- functionName: 'getAmountsOut',
190
- allowFailure: true,
191
- args: [amountIn, path],
192
- target,
193
- })),
194
- ),
195
- })
196
- }
197
-
198
- /**
199
- * Fetch the price corrective for the given bridge key, asset out, measurement token, from chain client, to chain client, asset link, amount in, and is prod
200
- * @param bridgeKeyPartner - the bridge key partner
201
- * @param assetOut - the asset out
202
- * @param measurementToken - the measurement token
203
- * @param fromChainClient - the from chain client
204
- * @param toChainClient - the to chain client
205
- * @param assetLink - the asset link
206
- * @param amountIn - the amount in
207
- * @param isProd - whether to use the production pathway
208
- * @returns the price corrective
209
- */
210
- export const fetchPriceCorrective = ({
211
- bridgeKeyPartner,
212
- assetOut,
213
- measurementToken,
214
- fromChainClient,
215
- toChainClient,
216
- assetLink,
217
- amountIn,
218
- isProd,
219
- }: {
220
- bridgeKey: BridgeKey,
221
- bridgeKeyPartner: BridgeKey,
222
- measurementToken: Hex,
223
- assetOut: Token,
224
- fromChainClient: PublicClient,
225
- toChainClient: PublicClient,
226
- assetLink: TokenBridgeInfo,
227
- amountIn: bigint,
228
- isProd: boolean,
229
- }) => {
230
- return {
231
- getPaymentToken: async () => {
232
- // fetch the token bridge info for the token that is about to be spent by the delivery service
233
- return await tokenBridgeInfo({
234
- bridgeKey: bridgeKeyPartner,
235
- assetIn: {
236
- ...assetOut,
237
- address: measurementToken,
238
- },
239
- isProd,
240
- // clients are reversed here because we are actually fetching the
241
- // tokens going the opposite direction to the provided bridge key
242
- fromChainClient: toChainClient,
243
- toChainClient: fromChainClient,
244
- })
245
- },
246
- getSwapResults: async ({
247
- paymentTokenResult,
248
- chain,
249
- uniV2Router,
250
- client,
251
- }: {
252
- paymentTokenResult: TokenBridgeInfo
253
- chain: Chains
254
- client: PublicClient
255
- uniV2Router?: Hex
256
- }) => {
257
- return await Promise.all([
258
- readAmountOut({
259
- amountIn,
260
- chain,
261
- uniV2Router,
262
- client,
263
- paths: [
264
- // check the direct route
265
- [assetLink.assetInAddress, paymentTokenResult!.assetOutAddress!],
266
- // might have heavier liquidity going through the native asset on the home side
267
- [assetLink.assetInAddress, nativeAssetOut[chain], paymentTokenResult!.assetOutAddress!],
268
- ],
269
- }),
270
- readAmountOut({
271
- amountIn,
272
- chain,
273
- uniV2Router,
274
- client,
275
- paths: [[assetOut.address as Hex, measurementToken]],
276
- // only the direct route is available.
277
- // might be able to create a whitelist for this at some point
278
- }),
279
- ])
280
- },
281
- reduceResults: ({
282
- results,
283
- oneToken,
284
- }: {
285
- results: [FetchResult[], ...[FetchResult[]]]
286
- oneToken: bigint
287
- }) => {
288
- const outputFromRouter = (result: FetchResult) => {
289
- if (_.isString(result)) {
290
- // the router failed to return a result
291
- return 0n
292
- }
293
- if (!result.length) {
294
- // the router returned an empty result
295
- return 0n
296
- }
297
- // the last element is the amount of the output token
298
- const last = result[result.length - 1]!
299
- return (last * oneToken) / amountIn
300
- }
301
- const max = (amountsOut: (bigint | undefined)[]) => {
302
- return _.compact(amountsOut).reduce((max, current) => (max < current ? current : max), 0n)
303
- }
304
- // could do with a refactor to unify the results
305
- const [outputs, inputs] = results
306
- const outputAmounts = outputs.map(outputFromRouter)
307
- const inputAmounts = inputs.map(outputFromRouter)
308
- const outputToken = max(outputAmounts)
309
- const inputToken = max(inputAmounts)
310
- const result =
311
- outputToken && outputToken > 0n
312
- ? inputToken && inputToken > outputToken && inputToken / outputToken === 1n
313
- ? inputToken
314
- : outputToken
315
- : inputToken
316
- return result
317
- }
318
- }
319
- }
320
-
321
- /**
322
- * Fetch the minimum bridge amount in for the given asset in, pathway, from public client, and to public client
323
- * @param assetIn - the asset in
324
- * @param pathway - the pathway
325
- * @param fromPublicClient - the from public client
326
- * @param toPublicClient - the to public client
327
- * @returns the minimum bridge amount in
328
- */
329
- export const minBridgeAmountIn = async ({
330
- assetIn,
331
- pathway,
332
- fromPublicClient,
333
- toPublicClient,
334
- }: {
335
- assetIn: Token,
336
- pathway: Pathway,
337
- fromPublicClient: PublicClient,
338
- toPublicClient: PublicClient,
339
- }) => {
340
- const publicClient = pathway?.feeManager === 'from' ? fromPublicClient : toPublicClient
341
- return publicClient.readContract({
342
- abi: abis.inputBridge,
343
- functionName: 'minPerTx',
344
- args: [assetIn.address as Hex],
345
- address: pathway[pathway.feeManager],
346
- })
347
- }
348
- /** get the symbol of the native asset, unwrap it if it needs to be */
349
- export const nativeSymbol = (asset: { address: string, symbol: string, chainId: number } | null, unwrap = false) => {
350
- return asset ? (unwrap && asset.address === nativeAssetOut[toChain(asset.chainId)] ? asset.symbol.slice(1) : asset.symbol) : ''
351
- }
352
-
353
- /** The input for loading the bridge fees */
354
- export type InputLoadFeeFor = {
355
- pathway: Pathway
356
- fromChainClient: PublicClient
357
- toChainClient: PublicClient
358
- }
359
-
360
- /** The fee configuration for a given pathway */
361
- export type PathwayExtendableConfig = {
362
- feeManager: Hex
363
- feeH2F: bigint
364
- feeF2H: bigint
365
- }
366
- /**
367
- * Returns the chain multicall for the given client
368
- * @param client - the client
369
- * @returns the chain multicall
370
- */
371
- export const chainMulticall = (client: PublicClient) => {
372
- const chainId = client.chain!.id
373
- const metadata = chainsMetadata[toChain(chainId)]
374
- return getContract({
375
- abi: multicall3Abi,
376
- client: client as any,
377
- address: metadata.contracts!.multicall3!.address,
378
- }) as any
379
- }
380
- /**
381
- * Load the bridge fees for the given pathway, from chain client, and to chain client
382
- * @param pathway - the pathway
383
- * @param fromChainClient - the from chain client
384
- * @param toChainClient - the to chain client
385
- * @returns the bridge fees
386
- */
387
- export const loadBridgeFees = async ({ pathway, fromChainClient, toChainClient }: InputLoadFeeFor) => {
388
- const multicall = pathway.feeManager === 'from'
389
- ? chainMulticall(fromChainClient)
390
- : chainMulticall(toChainClient)
391
-
392
- const [feeManagerResponse] = await multicall.read.aggregate3([
393
- [
394
- {
395
- allowFailure: false,
396
- target: pathway[pathway.feeManager],
397
- callData: encodeFunctionData({
398
- abi: abis.inputBridge,
399
- functionName: 'feeManager',
400
- }),
401
- },
402
- ],
403
- ])
404
- const { success, returnData } = feeManagerResponse
405
- if (!success) {
406
- throw new Error('unable to load feeManager')
407
- }
408
- if (returnData === '0x') {
409
- throw new Error('unable to read feeManager')
410
- }
411
- const feeManager = (
412
- returnData.startsWith('0x000000000000000000000000')
413
- ? `0x${returnData.slice(26)}`
414
- : `0x${returnData.slice(-40)}`
415
- ) as Hex
416
- const [keyH2F, keyF2H] = await multicall.read.aggregate3([
417
- [
418
- {
419
- allowFailure: false,
420
- target: feeManager,
421
- callData: encodeFunctionData({
422
- abi: abis.feeManager,
423
- functionName: 'HOME_TO_FOREIGN_FEE',
424
- }),
425
- },
426
- {
427
- allowFailure: false,
428
- target: feeManager,
429
- callData: encodeFunctionData({
430
- abi: abis.feeManager,
431
- functionName: 'FOREIGN_TO_HOME_FEE',
432
- }),
433
- },
434
- ],
435
- ])
436
- const [feeH2F, feeF2H] = await multicall.read.aggregate3([
437
- [
438
- {
439
- allowFailure: false,
440
- target: feeManager,
441
- callData: encodeFunctionData({
442
- abi: abis.feeManager,
443
- functionName: 'getFee',
444
- args: [keyH2F.returnData, zeroAddress],
445
- }),
446
- },
447
- {
448
- allowFailure: false,
449
- target: feeManager,
450
- callData: encodeFunctionData({
451
- abi: abis.feeManager,
452
- functionName: 'getFee',
453
- args: [keyF2H.returnData, zeroAddress],
454
- }),
455
- },
456
- ],
457
- ])
458
- const setting = {
459
- feeManager,
460
- feeH2F: BigInt(feeH2F.returnData),
461
- feeF2H: BigInt(feeF2H.returnData),
462
- } as PathwayExtendableConfig
463
- return setting
464
- }
package/src/chains.ts DELETED
@@ -1,88 +0,0 @@
1
- import { mainnet, pulsechain, bsc, sepolia, pulsechainV4 } from '@reown/appkit/networks'
2
- import { Chains } from '@gibs/bridge-sdk/config'
3
- import type { ChainsMetadata } from '@gibs/bridge-sdk/types'
4
- import * as imageLinks from '@gibs/bridge-sdk/image-links'
5
-
6
- /**
7
- * all of the chains that are enabled in this dapp
8
- * and their corresponding useful metadata
9
- */
10
- export const chainsMetadata = {
11
- [Chains.PLS]: {
12
- ...pulsechain,
13
- chainId: Chains.PLS,
14
- logoURI: imageLinks.network(pulsechain.id),
15
- alt: 'a pink blue and purple hexagon with an ekg line running horizontally',
16
- rpcUrls: {
17
- default: {
18
- http: ['https://rpc.pulsechain.com'],
19
- },
20
- },
21
- contracts: {
22
- ...pulsechain.contracts,
23
- ensRegistry: {
24
- address: '0xbd5133993FCDED5945c5539D9f032261F0d13170',
25
- },
26
- ensUniversalResolver: {
27
- address: '0x2FDBb906b4FE68e31D928C1ED0b6a3bD1f204374',
28
- blockCreated: 19_400_610,
29
- },
30
- },
31
- },
32
- [Chains.ETH]: {
33
- ...mainnet,
34
- chainId: Chains.ETH,
35
- logoURI: imageLinks.network(mainnet.id),
36
- alt: 'two pyramids joined on one side',
37
- rpcUrls: {
38
- default: {
39
- http: ['https://rpc-ethereum.g4mm4.io'],
40
- },
41
- },
42
- },
43
- [Chains.BNB]: {
44
- ...bsc,
45
- name: 'Binance Smart Chain',
46
- chainId: Chains.BNB,
47
- logoURI: imageLinks.network(bsc.id),
48
- alt: 'a gold cube with slits in the middle of each side',
49
- rpcUrls: {
50
- default: {
51
- http: ['https://bsc-rpc.publicnode.com'],
52
- },
53
- },
54
- },
55
- [Chains.SEP]: {
56
- ...sepolia,
57
- name: 'Sepolia',
58
- chainId: Chains.SEP,
59
- logoURI: imageLinks.network(sepolia.id),
60
- alt: 'two pyramids joined on one side',
61
- rpcUrls: {
62
- default: {
63
- http: ['https://ethereum-sepolia-rpc.publicnode.com'],
64
- },
65
- },
66
- },
67
- [Chains.V4PLS]: {
68
- ...pulsechainV4,
69
- name: 'Pulsechain V4',
70
- chainId: Chains.V4PLS,
71
- logoURI: imageLinks.network(pulsechainV4.id),
72
- alt: 'a pink blue and purple hexagon with an ekg line running horizontally',
73
- rpcUrls: {
74
- default: {
75
- http: ['https://rpc-testnet-pulsechain.g4mm4.io'],
76
- },
77
- },
78
- contracts: {
79
- ...pulsechainV4.contracts,
80
- ensRegistry: {
81
- address: '0xaDB38309aF7F85034FDC35bd6E6B45d1216CfB56',
82
- },
83
- ensUniversalResolver: {
84
- address: '0xDDFde3fA938dE0cdff82645579d03Ed750DE2e69',
85
- },
86
- },
87
- },
88
- } as ChainsMetadata