@gibs/bridge-sdk 1.6.34 → 1.7.1

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.
@@ -60,7 +60,7 @@ export declare const minBridgeAmountIn: ({ assetIn, pathway, fromPublicClient, t
60
60
  }) => Promise<bigint>;
61
61
  /** get the symbol of the native asset, unwrap it if it needs to be */
62
62
  export declare const nativeSymbol: (asset: {
63
- address: Hex;
63
+ address: string;
64
64
  symbol: string;
65
65
  chainId: number;
66
66
  } | null, unwrap?: boolean) => string;
@@ -17,7 +17,7 @@ export const links = _.memoize(async ({ chainId, target, address, client }) => {
17
17
  });
18
18
  }, ({ chainId, target, address }) => `${chainId}-${target}-${address}`.toLowerCase());
19
19
  export const tokenBridgeInfo = async ({ bridgeKey, assetIn, isProd, fromChainClient, toChainClient, }) => {
20
- const bridgePathway = pathway(bridgeKey, isProd);
20
+ const bridgePathway = pathway(bridgeKey, isProd, assetIn?.address);
21
21
  if (!assetIn || !bridgePathway) {
22
22
  console.log('missing asset in or bridge pathway');
23
23
  return null;
@@ -48,19 +48,20 @@ export const tokenBridgeInfo = async ({ bridgeKey, assetIn, isProd, fromChainCli
48
48
  originationChainId: fromChain,
49
49
  assetInAddress: assetInAddress,
50
50
  assetOutAddress: toBridged,
51
- toForeign: {
52
- foreign: toBridged,
53
- home: assetInAddress,
51
+ toHome: {
52
+ home: toBridged,
53
+ foreign: assetInAddress,
54
54
  },
55
55
  };
56
56
  }
57
57
  if (toNative !== zeroAddress) {
58
58
  // if (notGas) console.log('toNative')
59
+ console.log('toNative', toNative);
59
60
  return {
60
61
  originationChainId: toChain,
61
62
  assetInAddress: assetInAddress,
62
63
  assetOutAddress: toNative,
63
- toHome: {
64
+ toForeign: {
64
65
  home: toNative,
65
66
  foreign: assetInAddress,
66
67
  },
@@ -69,6 +70,7 @@ export const tokenBridgeInfo = async ({ bridgeKey, assetIn, isProd, fromChainCli
69
70
  const [fromBridged, fromNative] = fromMappings;
70
71
  if (fromNative !== zeroAddress) {
71
72
  // if (notGas) console.log('fromNative')
73
+ console.log('fromNative', fromNative);
72
74
  return {
73
75
  originationChainId: toChain,
74
76
  assetInAddress: assetInAddress,
@@ -19,6 +19,7 @@ export declare enum Provider {
19
19
  TOKENSEX = "tokensex"
20
20
  }
21
21
  export declare const nativeAssetOut: Record<Chains, Hex>;
22
+ export declare const deprecatedNativeAssetOut: Partial<Record<Chains, Set<Hex>>>;
22
23
  export declare const uniV2Routers: Record<Chains, Hex[]>;
23
24
  export declare const nativeTokenSymbol: Record<Chains, string>;
24
25
  export declare const nativeTokenName: Record<Chains, string>;
@@ -33,6 +34,8 @@ export type Pathway = {
33
34
  feeManager: 'from' | 'to';
34
35
  toHome: boolean;
35
36
  requiresDelivery: boolean;
37
+ bridgedNativeAssetOut: Hex;
38
+ settingOverrides?: Record<Hex, Partial<Pathway>>;
36
39
  };
37
40
  export type DeepPathwayConfig = Record<Provider, Partial<Record<Chains, Partial<Record<Chains, Pathway>>>>>;
38
41
  export declare const pathways: DeepPathwayConfig;
@@ -44,8 +47,8 @@ export declare const inferBridgeKey: ({ currentKey, provider, fromChain, toChain
44
47
  fromChain?: Chains;
45
48
  toChain?: Chains;
46
49
  }) => BridgeKey;
47
- export declare const pathway: (bridgeKey: BridgeKey | null, isProd: boolean) => Pathway | undefined;
50
+ export declare const pathway: (bridgeKey: BridgeKey | null, isProd: boolean, assetInAddress?: string | Hex | null | undefined) => Pathway | undefined;
48
51
  export declare const defaultAssetIn: ($bridgeKey: BridgeKey | null, isProd: boolean) => Token | undefined;
49
52
  export declare const isNative: (asset: Token | TokenOut | null, bridgeKey: BridgeKey | null) => boolean;
50
- export declare const isUnwrappable: (asset: Pick<Token, "extensions"> | null, bridgeKey: BridgeKey | null) => boolean;
53
+ export declare const isUnwrappable: (bridgeKey: BridgeKey | null, assetIn: Pick<Token, "address"> | null) => boolean;
51
54
  export declare const canChangeUnwrap: (bridgeKey: BridgeKey, assetIn: Token | null) => boolean;
@@ -1,4 +1,4 @@
1
- import { zeroAddress } from "viem";
1
+ import { getAddress, zeroAddress } from "viem";
2
2
  import _ from 'lodash';
3
3
  import * as imageLinks from '@gibs/bridge-sdk/image-links';
4
4
  /**
@@ -29,6 +29,9 @@ export const nativeAssetOut = {
29
29
  [Chains.SEP]: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
30
30
  [Chains.V4PLS]: '0x70499adEBB11Efd915E3b69E700c331778628707',
31
31
  };
32
+ export const deprecatedNativeAssetOut = {
33
+ [Chains.PLS]: new Set(['0x97Ac4a2439A47c07ad535bb1188c989dae755341']),
34
+ };
32
35
  export const uniV2Routers = {
33
36
  [Chains.PLS]: [
34
37
  '0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02',
@@ -56,6 +59,12 @@ export const nativeTokenName = {
56
59
  [Chains.SEP]: 'Sepolia Ether',
57
60
  [Chains.BNB]: 'BNB',
58
61
  };
62
+ const pulsechainPLSETHSettings = {
63
+ from: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
64
+ to: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
65
+ destinationRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
66
+ nativeRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
67
+ };
59
68
  export const pathways = {
60
69
  [Provider.PULSECHAIN]: {
61
70
  [Chains.PLS]: {
@@ -69,6 +78,12 @@ export const pathways = {
69
78
  feeManager: 'from',
70
79
  toHome: false,
71
80
  requiresDelivery: true,
81
+ // weth from ethereum on pulsechain
82
+ bridgedNativeAssetOut: '0x02DcdD04e3F455D838cd1249292C58f3B79e3C3C',
83
+ settingOverrides: {
84
+ [zeroAddress]: pulsechainPLSETHSettings,
85
+ [getAddress(nativeAssetOut[Chains.PLS])]: pulsechainPLSETHSettings,
86
+ },
72
87
  defaultAssetIn: {
73
88
  symbol: 'WETH',
74
89
  name: 'Wrapped Ether from Ethereum',
@@ -97,6 +112,16 @@ export const pathways = {
97
112
  usesExtraParam: false,
98
113
  toHome: true,
99
114
  requiresDelivery: false,
115
+ // wpls from pulsechain on ethereum
116
+ bridgedNativeAssetOut: '0xA882606494D86804B5514E07e6Bd2D6a6eE6d68A',
117
+ settingOverrides: {
118
+ [getAddress('0xa882606494d86804b5514e07e6bd2d6a6ee6d68a')]: {
119
+ from: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
120
+ to: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
121
+ destinationRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
122
+ nativeRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
123
+ },
124
+ },
100
125
  defaultAssetIn: {
101
126
  chainId: 1,
102
127
  address: nativeAssetOut[Chains.ETH],
@@ -127,6 +152,8 @@ export const pathways = {
127
152
  usesExtraParam: true,
128
153
  toHome: false,
129
154
  requiresDelivery: true,
155
+ // wbnb from bsc on pulsechain (tokensex)
156
+ bridgedNativeAssetOut: '0x518076CCE3729eF1a3877EA3647a26e278e764FE',
130
157
  defaultAssetIn: {
131
158
  symbol: 'WBNB',
132
159
  name: 'Wrapped BNB',
@@ -155,6 +182,8 @@ export const pathways = {
155
182
  usesExtraParam: true,
156
183
  toHome: true,
157
184
  requiresDelivery: false,
185
+ // wpls from pulsechain on bsc (tokensex)
186
+ bridgedNativeAssetOut: '0xF6088134D28eeBEF7128BA41FaDb2FCA0666c64C',
158
187
  defaultAssetIn: {
159
188
  chainId: 56,
160
189
  address: nativeAssetOut[Chains.BNB],
@@ -210,6 +239,7 @@ export const testnetPathways = {
210
239
  requiresDelivery: true,
211
240
  toHome: false,
212
241
  feeManager: 'from',
242
+ bridgedNativeAssetOut: '0x3677bd78ccf4d299328ecfba61790cf8dbfcf686',
213
243
  defaultAssetIn: {
214
244
  chainId: 943,
215
245
  address: '0x3677bd78CCf4d299328ECFBa61790cf8dBfcF686',
@@ -238,6 +268,7 @@ export const testnetPathways = {
238
268
  requiresDelivery: false,
239
269
  toHome: true,
240
270
  feeManager: 'to',
271
+ bridgedNativeAssetOut: '0x35807560aD0597E23F452cdc82D4Fb0e7E3c6590',
241
272
  defaultAssetIn: {
242
273
  chainId: 11_155_111,
243
274
  address: nativeAssetOut[Chains.SEP],
@@ -285,10 +316,20 @@ export const inferBridgeKey = ({ currentKey, provider, fromChain, toChain, }) =>
285
316
  : Object.keys(pathways[provider][nextFromChain])[0];
286
317
  return [provider, nextFromChain, nextToChain];
287
318
  };
288
- export const pathway = (bridgeKey, isProd) => {
319
+ export const pathway = (bridgeKey, isProd, assetInAddress) => {
289
320
  if (!bridgeKey)
290
321
  return;
291
- return _.get(pathways, bridgeKey) || (!isProd ? _.get(testnetPathways, bridgeKey) : undefined);
322
+ let pathway = _.get(pathways, bridgeKey) || (!isProd ? _.get(testnetPathways, bridgeKey) : undefined);
323
+ if (assetInAddress) {
324
+ const addr = getAddress(assetInAddress);
325
+ if (pathway?.settingOverrides?.[addr]) {
326
+ pathway = {
327
+ ...pathway,
328
+ ...pathway.settingOverrides[addr],
329
+ };
330
+ }
331
+ }
332
+ return pathway;
292
333
  };
293
334
  export const defaultAssetIn = ($bridgeKey, isProd) => {
294
335
  const conf = pathway($bridgeKey, isProd);
@@ -299,15 +340,22 @@ export const isNative = (asset, bridgeKey) => {
299
340
  if (!bridgeKey || !asset) {
300
341
  return false;
301
342
  }
302
- return ((asset.address === zeroAddress ||
303
- nativeAssetOut[toChain(asset.chainId)]?.toLowerCase() === asset.address?.toLowerCase()) &&
304
- !asset.name.includes(' from Pulsechain'));
343
+ const path = pathway(bridgeKey, false);
344
+ return (getAddress(asset.address) === getAddress(path.bridgedNativeAssetOut) ||
345
+ (asset.address === zeroAddress ||
346
+ nativeAssetOut[toChain(asset.chainId)]?.toLowerCase() === asset.address?.toLowerCase()) &&
347
+ !asset.name.includes(' from Pulsechain'));
305
348
  };
306
- export const isUnwrappable = (asset, bridgeKey) => {
307
- if (!bridgeKey || !asset) {
349
+ export const isUnwrappable = (bridgeKey, assetIn) => {
350
+ if (!bridgeKey || !assetIn) {
308
351
  return false;
309
352
  }
310
- const [, , toChain] = bridgeKey;
311
- return nativeAssetOut[toChain] === asset.extensions?.bridgeInfo?.[Number(toChain)]?.tokenAddress;
353
+ const addr = getAddress(assetIn.address);
354
+ const path = pathway(bridgeKey, false);
355
+ if (!path)
356
+ return false;
357
+ return path.bridgedNativeAssetOut === getAddress(addr);
358
+ };
359
+ export const canChangeUnwrap = (bridgeKey, assetIn) => {
360
+ return !!assetIn && isUnwrappable(bridgeKey, assetIn);
312
361
  };
313
- export const canChangeUnwrap = (bridgeKey, assetIn) => !!assetIn && isUnwrappable(assetIn, bridgeKey);