@openocean.finance/widget 1.0.41 → 1.0.44

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 (148) hide show
  1. package/dist/esm/App.js.map +1 -1
  2. package/dist/esm/AppDrawer.style.d.ts +1 -1
  3. package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +2 -2
  4. package/dist/esm/components/AmountInput/AmountInput.style.d.ts +1 -1
  5. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
  6. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +37 -33
  7. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  8. package/dist/esm/components/Avatar/Avatar.style.d.ts +1 -1
  9. package/dist/esm/components/Avatar/SmallAvatar.d.ts +1 -1
  10. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +1 -1
  11. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
  12. package/dist/esm/components/ButtonTertiary.d.ts +1 -1
  13. package/dist/esm/components/Card/CardHeader.d.ts +1 -1
  14. package/dist/esm/components/Card/CardIconButton.d.ts +1 -1
  15. package/dist/esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -1
  16. package/dist/esm/components/Header/Header.style.d.ts +2 -2
  17. package/dist/esm/components/Header/SettingsButton.style.d.ts +2 -2
  18. package/dist/esm/components/ListItem/ListItem.d.ts +1 -1
  19. package/dist/esm/components/Messages/WarningMessages.js +1 -0
  20. package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
  21. package/dist/esm/components/Messages/useMessageQueue.js +1 -1
  22. package/dist/esm/components/Messages/useMessageQueue.js.map +1 -1
  23. package/dist/esm/components/Search/SearchInput.style.d.ts +1 -1
  24. package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  25. package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  26. package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +2 -2
  27. package/dist/esm/components/StepActions/StepActions.style.d.ts +1 -1
  28. package/dist/esm/components/Tabs/Tabs.style.d.ts +2 -2
  29. package/dist/esm/components/TokenList/TokenList.style.d.ts +2 -2
  30. package/dist/esm/components/TransactionDetails.js +1 -1
  31. package/dist/esm/components/TransactionDetails.js.map +1 -1
  32. package/dist/esm/config/defaultChainIds.js +3 -0
  33. package/dist/esm/config/defaultChainIds.js.map +1 -1
  34. package/dist/esm/config/version.d.ts +1 -1
  35. package/dist/esm/config/version.js +1 -1
  36. package/dist/esm/cross/adapters/AcrossAdapter.js +21 -22
  37. package/dist/esm/cross/adapters/AcrossAdapter.js.map +1 -1
  38. package/dist/esm/cross/adapters/BaseSwapAdapter.d.ts +17 -9
  39. package/dist/esm/cross/adapters/BaseSwapAdapter.js +15 -4
  40. package/dist/esm/cross/adapters/BaseSwapAdapter.js.map +1 -1
  41. package/dist/esm/cross/adapters/DebridgeAdapter.js +8 -7
  42. package/dist/esm/cross/adapters/DebridgeAdapter.js.map +1 -1
  43. package/dist/esm/cross/adapters/LifiAdapter.js +7 -6
  44. package/dist/esm/cross/adapters/LifiAdapter.js.map +1 -1
  45. package/dist/esm/cross/adapters/MayanAdapter.js +1 -2
  46. package/dist/esm/cross/adapters/MayanAdapter.js.map +1 -1
  47. package/dist/esm/cross/adapters/NearIntentsAdapter.d.ts +13 -6
  48. package/dist/esm/cross/adapters/NearIntentsAdapter.js +252 -75
  49. package/dist/esm/cross/adapters/NearIntentsAdapter.js.map +1 -1
  50. package/dist/esm/cross/adapters/OptimexAdapter.js +2 -1
  51. package/dist/esm/cross/adapters/OptimexAdapter.js.map +1 -1
  52. package/dist/esm/cross/adapters/OrbiterAdapter.js +9 -8
  53. package/dist/esm/cross/adapters/OrbiterAdapter.js.map +1 -1
  54. package/dist/esm/cross/adapters/RelayAdapter.js +46 -15
  55. package/dist/esm/cross/adapters/RelayAdapter.js.map +1 -1
  56. package/dist/esm/cross/adapters/SymbiosisAdapter.js +13 -14
  57. package/dist/esm/cross/adapters/SymbiosisAdapter.js.map +1 -1
  58. package/dist/esm/cross/adapters/XYFinanceAdapter.js +13 -17
  59. package/dist/esm/cross/adapters/XYFinanceAdapter.js.map +1 -1
  60. package/dist/esm/cross/adapters/index.d.ts +2 -0
  61. package/dist/esm/cross/adapters/index.js +2 -1
  62. package/dist/esm/cross/adapters/index.js.map +1 -1
  63. package/dist/esm/cross/constants/index.d.ts +3 -1
  64. package/dist/esm/cross/constants/index.js +2 -0
  65. package/dist/esm/cross/constants/index.js.map +1 -1
  66. package/dist/esm/cross/crossChainQuote.d.ts +1 -1
  67. package/dist/esm/cross/crossChainQuote.js +22 -12
  68. package/dist/esm/cross/crossChainQuote.js.map +1 -1
  69. package/dist/esm/cross/factory.d.ts +3 -1
  70. package/dist/esm/cross/factory.js +10 -12
  71. package/dist/esm/cross/factory.js.map +1 -1
  72. package/dist/esm/cross/registry.d.ts +1 -1
  73. package/dist/esm/hooks/useAvailableChains.js +47 -40
  74. package/dist/esm/hooks/useAvailableChains.js.map +1 -1
  75. package/dist/esm/hooks/useChains.js.map +1 -1
  76. package/dist/esm/hooks/useRoutes.js +11 -3
  77. package/dist/esm/hooks/useRoutes.js.map +1 -1
  78. package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
  79. package/dist/esm/hooks/useTokens.d.ts +1 -0
  80. package/dist/esm/hooks/useTokens.js +14 -0
  81. package/dist/esm/hooks/useTokens.js.map +1 -1
  82. package/dist/esm/index.js.map +1 -1
  83. package/dist/esm/pages/MainPage/MainPage.js +1 -2
  84. package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
  85. package/dist/esm/pages/MainPage/MainWarningMessages.js.map +1 -1
  86. package/dist/esm/pages/SendToWallet/BookmarksPage.js +1 -1
  87. package/dist/esm/pages/SendToWallet/BookmarksPage.js.map +1 -1
  88. package/dist/esm/pages/SendToWallet/RecentWalletsPage.js +2 -2
  89. package/dist/esm/pages/SendToWallet/RecentWalletsPage.js.map +1 -1
  90. package/dist/esm/pages/SendToWallet/SendToConfiguredWalletPage.js +2 -2
  91. package/dist/esm/pages/SendToWallet/SendToConfiguredWalletPage.js.map +1 -1
  92. package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +4 -4
  93. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +1 -1
  94. package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  95. package/dist/esm/services/ExecuteRoute.js +218 -9
  96. package/dist/esm/services/ExecuteRoute.js.map +1 -1
  97. package/dist/esm/services/OpenOceanService.js +30 -4
  98. package/dist/esm/services/OpenOceanService.js.map +1 -1
  99. package/dist/esm/stores/bookmarks/createBookmarkStore.js.map +1 -1
  100. package/dist/esm/utils/chainType.d.ts +1 -0
  101. package/dist/esm/utils/chainType.js +15 -0
  102. package/dist/esm/utils/chainType.js.map +1 -1
  103. package/dist/esm/utils/getPriceImpact.js +3 -3
  104. package/dist/esm/utils/getPriceImpact.js.map +1 -1
  105. package/package.json +18 -6
  106. package/src/App.tsx +0 -1
  107. package/src/components/AmountInput/AmountInputEndAdornment.tsx +39 -34
  108. package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -2
  109. package/src/components/Messages/WarningMessages.tsx +1 -0
  110. package/src/components/Messages/useMessageQueue.ts +1 -1
  111. package/src/components/TransactionDetails.tsx +4 -4
  112. package/src/config/defaultChainIds.ts +3 -0
  113. package/src/config/version.ts +1 -1
  114. package/src/cross/adapters/AcrossAdapter.ts +21 -22
  115. package/src/cross/adapters/BaseSwapAdapter.ts +24 -8
  116. package/src/cross/adapters/DebridgeAdapter.ts +11 -11
  117. package/src/cross/adapters/LifiAdapter.ts +11 -10
  118. package/src/cross/adapters/MayanAdapter.ts +1 -2
  119. package/src/cross/adapters/NearIntentsAdapter.ts +303 -129
  120. package/src/cross/adapters/OptimexAdapter.ts +12 -11
  121. package/src/cross/adapters/OrbiterAdapter.ts +17 -16
  122. package/src/cross/adapters/RelayAdapter.ts +50 -17
  123. package/src/cross/adapters/SymbiosisAdapter.ts +13 -14
  124. package/src/cross/adapters/XYFinanceAdapter.ts +15 -19
  125. package/src/cross/adapters/index.ts +2 -1
  126. package/src/cross/constants/index.ts +4 -0
  127. package/src/cross/crossChainQuote.ts +27 -21
  128. package/src/cross/factory.ts +12 -12
  129. package/src/cross/registry.ts +1 -1
  130. package/src/hooks/useAvailableChains.ts +50 -43
  131. package/src/hooks/useChains.ts +0 -1
  132. package/src/hooks/useExplorer.ts +6 -6
  133. package/src/hooks/useRoutes.ts +12 -4
  134. package/src/hooks/useTokenAddressBalance.ts +1 -1
  135. package/src/hooks/useTokens.ts +20 -5
  136. package/src/index.ts +0 -1
  137. package/src/pages/MainPage/MainPage.tsx +1 -1
  138. package/src/pages/MainPage/MainWarningMessages.tsx +0 -1
  139. package/src/pages/SendToWallet/BookmarksPage.tsx +1 -1
  140. package/src/pages/SendToWallet/RecentWalletsPage.tsx +2 -2
  141. package/src/pages/SendToWallet/SendToConfiguredWalletPage.tsx +2 -2
  142. package/src/providers/WidgetProvider/WidgetProvider.tsx +0 -1
  143. package/src/services/ExecuteRoute.ts +315 -64
  144. package/src/services/OpenOceanService.ts +31 -7
  145. package/src/stores/bookmarks/createBookmarkStore.ts +15 -15
  146. package/src/utils/chainType.ts +25 -1
  147. package/src/utils/getPriceImpact.ts +3 -3
  148. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -3,7 +3,7 @@ import { Currency } from '../constants/index.js'
3
3
  import { useWalletSelector } from '@near-wallet-selector/react-hook'
4
4
  import { WalletAdapterProps } from '@solana/wallet-adapter-base'
5
5
  import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js'
6
- import { getPublicClient } from '@wagmi/core'
6
+ import { getPublicClient } from 'wagmi/actions'
7
7
  import { WalletClient, formatUnits } from 'viem'
8
8
  import { useConfig } from 'wagmi'
9
9
  import { CROSS_CHAIN_FEE_RECEIVER, CROSS_CHAIN_FEE_RECEIVER_SOLANA, ZERO_ADDRESS } from '../constants/index.js'
@@ -53,27 +53,27 @@ export class OrbiterAdapter extends BaseSwapAdapter {
53
53
  const fromToken = params.fromToken as any
54
54
  const toToken = params.toToken as any
55
55
  const body = {
56
- sourceChainId: params.fromChain === 'solana' ? 'SOLANA_MAIN' : params.fromChain.toString(),
57
- destChainId: params.toChain === 'solana' ? 'SOLANA_MAIN' : params.toChain.toString(),
56
+ sourceChainId: params.fromChain === 1151111081099710 ? 'SOLANA_MAIN' : params.fromChain.toString(),
57
+ destChainId: params.toChain === 1151111081099710 ? 'SOLANA_MAIN' : params.toChain.toString(),
58
58
  sourceToken:
59
- params.fromChain === 'solana'
59
+ params.fromChain === 1151111081099710
60
60
  ? (params.fromToken as SolanaToken).id
61
61
  : fromToken.isNative
62
- ? ZERO_ADDRESS
63
- : fromToken.address,
62
+ ? ZERO_ADDRESS
63
+ : fromToken.address,
64
64
 
65
65
  destToken:
66
- params.toChain === 'solana'
66
+ params.toChain === 1151111081099710
67
67
  ? (params.toToken as SolanaToken).id
68
68
  : toToken.isNative
69
- ? ZERO_ADDRESS
70
- : toToken.address,
69
+ ? ZERO_ADDRESS
70
+ : toToken.address,
71
71
  amount: params.amount.toString(),
72
72
  userAddress: params.sender,
73
73
  targetRecipient: params.recipient,
74
74
  slippage: params.slippage / 10_000,
75
75
  feeConfig: {
76
- feeRecipient: params.fromChain === 'solana' ? CROSS_CHAIN_FEE_RECEIVER_SOLANA : CROSS_CHAIN_FEE_RECEIVER,
76
+ feeRecipient: params.fromChain === 1151111081099710 ? CROSS_CHAIN_FEE_RECEIVER_SOLANA : CROSS_CHAIN_FEE_RECEIVER,
77
77
  feePercent: (params.feeBps / 10000).toString(),
78
78
  },
79
79
  channel: 'kyberswap',
@@ -127,7 +127,7 @@ export class OrbiterAdapter extends BaseSwapAdapter {
127
127
  sendSolanaFn?: WalletAdapterProps['sendTransaction'],
128
128
  solanaConnection?: Connection,
129
129
  ): Promise<NormalizedTxResponse> {
130
- if (quote.quoteParams.fromChain === 'solana') {
130
+ if (quote.quoteParams.fromChain === 1151111081099710) {
131
131
  if (!solanaConnection || !sendSolanaFn) throw new Error('Connection is not defined for Solana swap')
132
132
  const encodedData = quote.rawQuote.steps?.[0]?.tx?.data
133
133
  const txBuffer = Buffer.from(encodedData, 'base64')
@@ -214,6 +214,7 @@ export class OrbiterAdapter extends BaseSwapAdapter {
214
214
  to: step.tx.to as `0x${string}`,
215
215
  value: BigInt(step.tx.value),
216
216
  data: step.tx.data as `0x${string}`,
217
+ kzg: undefined,
217
218
  })
218
219
  return tx
219
220
  }),
@@ -237,7 +238,7 @@ export class OrbiterAdapter extends BaseSwapAdapter {
237
238
  }
238
239
 
239
240
  async getTransactionStatus(p: NormalizedTxResponse): Promise<SwapStatus> {
240
- if (p.sourceChain !== 'solana') {
241
+ if (p.sourceChain !== 1151111081099710) {
241
242
  const publicClient = getPublicClient(useConfig(), {
242
243
  chainId: p.sourceChain as any,
243
244
  })
@@ -261,10 +262,10 @@ export class OrbiterAdapter extends BaseSwapAdapter {
261
262
  res.result.opStatus === -1
262
263
  ? 'Failed'
263
264
  : res.result.opStatus === 80
264
- ? 'Refunded'
265
- : res.result.opStatus !== 98 && res.result.opStatus !== 99
266
- ? 'Processing'
267
- : 'Success',
265
+ ? 'Refunded'
266
+ : res.result.opStatus !== 98 && res.result.opStatus !== 99
267
+ ? 'Processing'
268
+ : 'Success',
268
269
  }
269
270
  }
270
271
  }
@@ -4,7 +4,8 @@ import {
4
4
  convertViemChainToRelayChain,
5
5
  createClient,
6
6
  getClient,
7
- } from '@reservoir0x/relay-sdk'
7
+ type QuoteBodyOptions,
8
+ } from '@relayprotocol/relay-sdk'
8
9
  import { type WalletClient, formatUnits } from 'viem'
9
10
  import {
10
11
  arbitrum,
@@ -24,6 +25,7 @@ import {
24
25
  sonic,
25
26
  unichain,
26
27
  zksync,
28
+ celo
27
29
  } from 'viem/chains'
28
30
  import type { Currency } from '../constants/index.js'
29
31
 
@@ -39,6 +41,7 @@ import {
39
41
  type Chain,
40
42
  NOT_SUPPORTED_CHAINS_PRICE_SERVICE,
41
43
  NonEvmChain,
44
+ NewEvmChain,
42
45
  type NormalizedQuote,
43
46
  type NormalizedTxResponse,
44
47
  type QuoteParams,
@@ -99,6 +102,9 @@ const plasma = defineChain({
99
102
 
100
103
 
101
104
  const SolanaChainId = 792703809
105
+ const BitcoinChainId = 8253038
106
+ const BitcoinAddress = 'bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8'
107
+ const MonadChainId = 143
102
108
 
103
109
  const solanaChain = {
104
110
  id: SolanaChainId,
@@ -107,6 +113,21 @@ const solanaChain = {
107
113
  vmType: 'svm' as const,
108
114
  } as RelayChain
109
115
 
116
+ const bitcoinChain = {
117
+ id: BitcoinChainId,
118
+ name: 'Bitcoin',
119
+ displayName: 'Bitcoin',
120
+ vmType: 'bvm' as const,
121
+ } as RelayChain
122
+
123
+
124
+ const MonadChain = {
125
+ id: MonadChainId,
126
+ name: 'Monad',
127
+ displayName: 'Monad',
128
+ vmType: 'evm' as const,
129
+ } as RelayChain
130
+
110
131
  export class RelayAdapter extends BaseSwapAdapter {
111
132
  constructor() {
112
133
  super()
@@ -132,10 +153,11 @@ export class RelayAdapter extends BaseSwapAdapter {
132
153
  ronin,
133
154
  unichain,
134
155
  hyperEvm,
135
- plasma
156
+ plasma,
157
+ celo,
136
158
  ]
137
159
  .map(convertViemChainToRelayChain)
138
- .concat(solanaChain as any),
160
+ .concat(solanaChain as any, bitcoinChain as any, MonadChain as any),
139
161
  })
140
162
  }
141
163
 
@@ -146,7 +168,7 @@ export class RelayAdapter extends BaseSwapAdapter {
146
168
  return 'https://storage.googleapis.com/ks-setting-1d682dca/84e906bb-eaeb-45d3-a64c-2aa9c84eb3ea1747759080942.png'
147
169
  }
148
170
  getSupportedChains(): Chain[] {
149
- return [NonEvmChain.Solana, NonEvmChain.Plasma, ...MAINNET_NETWORKS]
171
+ return [NonEvmChain.Solana, NonEvmChain.Bitcoin, NewEvmChain.Plasma, NewEvmChain.Monad, ...MAINNET_NETWORKS]
150
172
  // return [...MAINNET_NETWORKS]
151
173
  }
152
174
 
@@ -157,19 +179,30 @@ export class RelayAdapter extends BaseSwapAdapter {
157
179
  async getQuote(params: QuoteParams): Promise<NormalizedQuote> {
158
180
  const evmFromToken = params.fromToken as Currency
159
181
  const evmToToken = params.toToken as Currency
160
- const currency = evmFromToken.isNative ? ZERO_ADDRESS : evmFromToken.address
161
- const toCurrency = evmToToken.isNative ? ZERO_ADDRESS : evmToToken.address
162
- const resp = await getClient().actions.getQuote({
163
- chainId:
164
- params.fromChain === NonEvmChain.Solana
165
- ? SolanaChainId
166
- : +params.fromChain,
167
- toChainId:
168
- params.toChain === NonEvmChain.Solana ? SolanaChainId : +params.toChain,
182
+ let currency = evmFromToken.isNative ? ZERO_ADDRESS : evmFromToken.address
183
+ let toCurrency = evmToToken.isNative ? ZERO_ADDRESS : evmToToken.address
184
+
185
+ let chainId = +params.fromChain
186
+ if (params.fromChain === NonEvmChain.Solana) {
187
+ chainId = SolanaChainId
188
+ } else if (params.fromChain === NonEvmChain.Bitcoin) {
189
+ chainId = BitcoinChainId
190
+ currency = BitcoinAddress
191
+ }
192
+ let toChainId = +params.toChain
193
+ if (params.toChain === NonEvmChain.Solana) {
194
+ toChainId = SolanaChainId
195
+ } else if (params.toChain === NonEvmChain.Bitcoin) {
196
+ toChainId = BitcoinChainId
197
+ toCurrency = BitcoinAddress
198
+ }
199
+ const quoteParams = {
200
+ chainId: chainId,
201
+ toChainId: toChainId,
169
202
  currency,
170
203
  toCurrency,
171
204
  amount: params.amount,
172
- tradeType: 'EXACT_INPUT',
205
+ tradeType: 'EXACT_INPUT' as QuoteBodyOptions['tradeType'],
173
206
  wallet: params.walletClient,
174
207
  recipient: params.recipient,
175
208
  user: params.sender,
@@ -184,11 +217,11 @@ export class RelayAdapter extends BaseSwapAdapter {
184
217
  fee: params.feeBps.toString(),
185
218
  },
186
219
  ],
187
- protocolVersion:'preferV2'
220
+ protocolVersion: 'preferV2' as 'preferV2' | 'v1' | 'v2',
188
221
  // includedSwapSources: ['open-ocean'],
189
222
  },
190
- })
191
-
223
+ }
224
+ const resp = await getClient().actions.getQuote(quoteParams)
192
225
  const formattedOutputAmount = formatUnits(
193
226
  BigInt(resp.details?.currencyOut?.amount || '0'),
194
227
  params.toToken.decimals
@@ -30,20 +30,18 @@ export class SymbiosisAdapter extends BaseSwapAdapter {
30
30
  }
31
31
  getSupportedChains(): Chain[] {
32
32
  return [
33
- ChainId.MAINNET,
34
- ChainId.BSCMAINNET,
35
- ChainId.MATIC,
36
- ChainId.AVAXMAINNET,
37
- ChainId.ZKSYNC,
38
- ChainId.ARBITRUM,
39
- ChainId.OPTIMISM,
40
- ChainId.LINEA,
41
- ChainId.MANTLE,
42
- ChainId.BASE,
43
- ChainId.SCROLL,
44
- ChainId.BLAST,
45
- ChainId.SONIC,
46
- ChainId.BERA,
33
+ ChainId.ETH,
34
+ ChainId.BAS,
35
+ ChainId.POL,
36
+ ChainId.AVA,
37
+ // ChainId.ZKSYNC,
38
+ ChainId.ARB,
39
+ ChainId.OPT,
40
+ ChainId.LNA,
41
+ ChainId.BAS,
42
+ ChainId.SCL,
43
+ ChainId.BLS,
44
+ ChainId.UNI,
47
45
  ]
48
46
  }
49
47
 
@@ -118,6 +116,7 @@ export class SymbiosisAdapter extends BaseSwapAdapter {
118
116
  to: quote.rawQuote.tx.to,
119
117
  value: BigInt(quote.rawQuote.tx.value),
120
118
  data: quote.rawQuote.tx.data,
119
+ kzg: undefined,
121
120
  })
122
121
  return {
123
122
  sender: quote.quoteParams.sender,
@@ -1,6 +1,6 @@
1
1
  import { ChainId } from '@openocean.finance/widget-sdk'
2
2
  import { Currency } from '../constants/index.js'
3
- import { getPublicClient } from '@wagmi/core'
3
+ import { getPublicClient } from 'wagmi/actions'
4
4
  import { WalletClient, formatUnits } from 'viem'
5
5
  import { useConfig } from 'wagmi'
6
6
 
@@ -32,22 +32,17 @@ export class XYFinanceAdapter extends BaseSwapAdapter {
32
32
  }
33
33
  getSupportedChains(): Chain[] {
34
34
  return [
35
- ChainId.MAINNET,
36
- ChainId.BSCMAINNET,
37
- ChainId.MATIC,
38
- ChainId.FANTOM,
39
- ChainId.AVAXMAINNET,
40
- ChainId.ARBITRUM,
41
- ChainId.OPTIMISM,
42
- ChainId.ZKSYNC,
43
- ChainId.LINEA,
44
- ChainId.BASE,
45
- ChainId.MANTLE,
46
- ChainId.SCROLL,
47
- ChainId.BLAST,
48
- ChainId.BERA,
49
- ChainId.SONIC,
50
- ChainId.UNICHAIN,
35
+ ChainId.ETH,
36
+ ChainId.BSC,
37
+ ChainId.POL,
38
+ ChainId.AVA,
39
+ ChainId.ARB,
40
+ ChainId.OPT,
41
+ ChainId.LNA,
42
+ ChainId.BAS,
43
+ ChainId.SCL,
44
+ ChainId.BLS,
45
+ ChainId.UNI,
51
46
  ]
52
47
  }
53
48
 
@@ -145,8 +140,8 @@ export class XYFinanceAdapter extends BaseSwapAdapter {
145
140
  ...(quote.rawQuote.srcSwapDescription ? { srcSwapProvider: quote.rawQuote.srcSwapDescription.provider } : {}),
146
141
  ...(quote.rawQuote.dstSwapDescription
147
142
  ? {
148
- dstSwapProvider: quote.rawQuote.dstSwapDescription?.provider,
149
- }
143
+ dstSwapProvider: quote.rawQuote.dstSwapDescription?.provider,
144
+ }
150
145
  : {}),
151
146
  }
152
147
 
@@ -168,6 +163,7 @@ export class XYFinanceAdapter extends BaseSwapAdapter {
168
163
  to: resp.tx.to,
169
164
  value: resp.tx.value,
170
165
  data: resp.tx.data,
166
+ kzg: undefined,
171
167
  })
172
168
  return {
173
169
  sender: quote.quoteParams.sender,
@@ -1,4 +1,4 @@
1
- // export * from './BaseSwapAdapter.js'
1
+ export * from './BaseSwapAdapter.js'
2
2
  // export * from './AcrossAdapter.js'
3
3
  export * from './RelayAdapter.js'
4
4
  // export * from './XYFinanceAdapter.js'
@@ -7,3 +7,4 @@ export * from './MayanAdapter.js'
7
7
  // export * from './DebridgeAdapter.js'
8
8
  // export * from './LifiAdapter.js'
9
9
  // export * from './KyberSwapAdapter.js'
10
+ export * from './NearIntentsAdapter.js'
@@ -183,6 +183,8 @@ export const MAINNET_NETWORKS = [
183
183
  ChainId.UNI,
184
184
  ChainId.BLS,
185
185
  ChainId.SCL,
186
+ ChainId.CEL,
187
+ ChainId.MONAD,
186
188
  ] as const
187
189
 
188
190
  export interface Currency {
@@ -203,6 +205,7 @@ export interface Currency {
203
205
  }
204
206
 
205
207
  export interface NearToken {
208
+ address: string
206
209
  assetId: string
207
210
  decimals: number
208
211
  blockchain: string
@@ -214,6 +217,7 @@ export interface NearToken {
214
217
  }
215
218
 
216
219
  export interface SolanaToken {
220
+ address: string
217
221
  id: string
218
222
  name: string
219
223
  symbol: string
@@ -41,6 +41,11 @@ export async function getCrossChainQuote({
41
41
  CrossChainSwapFactory.getAllAdapters().forEach((adapter) => {
42
42
  registry.registerAdapter(adapter)
43
43
  })
44
+
45
+ let slippage = typeof slippage_tolerance === 'string'
46
+ ? Number.parseFloat(slippage_tolerance)
47
+ : slippage_tolerance
48
+ slippage = Math.floor(slippage * 10000) / 100
44
49
  // 2. Construct QuoteParams
45
50
  const params: QuoteParams = {
46
51
  feeBps,
@@ -49,20 +54,18 @@ export async function getCrossChainQuote({
49
54
  fromToken: fromMsg,
50
55
  toToken: toMsg,
51
56
  amount: inAmount,
52
- slippage:
53
- typeof slippage_tolerance === 'string'
54
- ? Number.parseFloat(slippage_tolerance)
55
- : slippage_tolerance,
57
+ slippage: slippage,
56
58
  walletClient,
57
59
  tokenInUsd,
58
60
  tokenOutUsd,
59
61
  sender: account,
60
62
  recipient: recipient || '',
61
63
  publicKey,
64
+ isNative: fromMsg.isNative || toMsg.isNative,
62
65
  }
63
66
 
64
67
  if (fromMsg.chainId === 'near' || toMsg.chainId === 'near') {
65
- ;(params as any).nearTokens = nearTokens
68
+ ; (params as any).nearTokens = nearTokens
66
69
  }
67
70
 
68
71
  // 3. Get all quotes
@@ -72,14 +75,13 @@ export async function getCrossChainQuote({
72
75
  adapter.getSupportedChains().includes(params.toChain)
73
76
  )
74
77
  })
75
-
76
78
  if (adapters.length === 0) {
77
79
  console.warn('No supported adapters found for the specified chains')
78
80
  return null
79
81
  }
80
82
 
81
83
  const quoteResults: Quote[] = []
82
-
84
+ let errorMsg = ''
83
85
  // Get quotes from all adapters in parallel
84
86
  const quotePromises = adapters.map(async (adapter) => {
85
87
  try {
@@ -88,6 +90,7 @@ export async function getCrossChainQuote({
88
90
  quoteResults.push({ adapter, quote })
89
91
  }
90
92
  } catch (error) {
93
+ errorMsg = error instanceof Error ? error.message : 'Unknown error'
91
94
  // Ignore individual adapter errors, continue getting quotes from other adapters
92
95
  console.warn(`Failed to get quote from ${adapter.getName()}:`, error)
93
96
  }
@@ -97,7 +100,8 @@ export async function getCrossChainQuote({
97
100
 
98
101
  if (quoteResults.length === 0) {
99
102
  console.warn('No valid quotes found from any adapter')
100
- return null
103
+ throw new Error(errorMsg)
104
+ // return { error: errorMsg }
101
105
  }
102
106
 
103
107
  // 4. Select best quote (highest outputAmount)
@@ -106,7 +110,6 @@ export async function getCrossChainQuote({
106
110
  )
107
111
 
108
112
  const best = quoteResults[0]
109
-
110
113
  // 5. Construct return structure compatible with useRoutes.ts
111
114
  return {
112
115
  data: {
@@ -114,8 +117,8 @@ export async function getCrossChainQuote({
114
117
  outAmount: best.quote.outputAmount || '0',
115
118
  fromTokenUSD: best.quote.inputUsd?.toString() || '0',
116
119
  toTokenUSD: best.quote.outputUsd?.toString() || '0',
117
- quoteAdapterName: best.adapter.getName(),
118
- quoteAdapterKey: best.adapter.getName().toLowerCase(),
120
+ quoteAdapterName: best.adapter?.getName() || '',
121
+ quoteAdapterKey: best.adapter?.getName()?.toLowerCase() || '',
119
122
  chainId: fromMsg.chainId,
120
123
  from: account,
121
124
 
@@ -130,7 +133,7 @@ export async function getCrossChainQuote({
130
133
  // Fee information
131
134
  feeCosts: [
132
135
  {
133
- name: `${best.adapter.getName()} Fee`,
136
+ name: `${best.adapter?.getName() || ''} Fee`,
134
137
  description: 'Protocol fee',
135
138
  token: fromMsg,
136
139
  amount: '0',
@@ -145,7 +148,7 @@ export async function getCrossChainQuote({
145
148
  }
146
149
  } catch (error) {
147
150
  console.error('Error getting cross-chain quote:', error)
148
- return null
151
+ throw error
149
152
  }
150
153
  }
151
154
 
@@ -158,14 +161,17 @@ export const bridgeExecuteSwap = async ({
158
161
  }) => {
159
162
  const adapterName = quoteData.quoteAdapterKey
160
163
  const adapter = CrossChainSwapFactory.getAdapterByName(adapterName)
161
- const result = await adapter.executeSwap(
162
- {
163
- quote: quoteData.quoteRawData,
164
- },
165
- walletClient
166
- )
167
-
168
- return result
164
+ if (adapter) {
165
+ const result = await adapter?.executeSwap(
166
+ {
167
+ adapter,
168
+ quote: quoteData.quoteRawData as any,
169
+ },
170
+ walletClient
171
+ )
172
+ return result
173
+ }
174
+ return null
169
175
  }
170
176
 
171
177
  // Login URL mapping for each adapter
@@ -1,4 +1,3 @@
1
- // import { NearIntentsAdapter } from './adapters/NearIntentsAdapter.js'
2
1
  // import { OptimexAdapter } from './adapters/OptimexAdapter.js'
3
2
  // import { OrbiterAdapter } from './adapters/OrbiterAdapter.js'
4
3
  import {
@@ -7,7 +6,8 @@ import {
7
6
  // LifiAdapter,
8
7
  MayanAdapter,
9
8
  RelayAdapter,
10
- // SwapProvider,
9
+ NearIntentsAdapter,
10
+ SwapProvider,
11
11
  // SymbiosisAdapter,
12
12
  // XYFinanceAdapter,
13
13
  } from './adapters/index.js'
@@ -18,7 +18,7 @@ export class CrossChainSwapFactory {
18
18
  // private static acrossInstance: AcrossAdapter
19
19
  private static relayInstance: RelayAdapter
20
20
  // private static xyFinanceInstance: XYFinanceAdapter
21
- // private static nearIntentsInstance: NearIntentsAdapter
21
+ private static nearIntentsInstance: NearIntentsAdapter
22
22
  private static mayanInstance: MayanAdapter
23
23
  // private static symbiosisInstance: SymbiosisAdapter
24
24
  // private static debridgeInstance: DeBridgeAdapter
@@ -49,12 +49,12 @@ export class CrossChainSwapFactory {
49
49
  // return CrossChainSwapFactory.xyFinanceInstance
50
50
  // }
51
51
 
52
- // static getNearIntentsAdapter(): NearIntentsAdapter {
53
- // if (!CrossChainSwapFactory.nearIntentsInstance) {
54
- // CrossChainSwapFactory.nearIntentsInstance = new NearIntentsAdapter()
55
- // }
56
- // return CrossChainSwapFactory.nearIntentsInstance
57
- // }
52
+ static getNearIntentsAdapter(): NearIntentsAdapter {
53
+ if (!CrossChainSwapFactory.nearIntentsInstance) {
54
+ CrossChainSwapFactory.nearIntentsInstance = new NearIntentsAdapter()
55
+ }
56
+ return CrossChainSwapFactory.nearIntentsInstance
57
+ }
58
58
 
59
59
  static getMayanAdapter(): MayanAdapter {
60
60
  if (!CrossChainSwapFactory.mayanInstance) {
@@ -103,10 +103,10 @@ export class CrossChainSwapFactory {
103
103
  return [
104
104
  CrossChainSwapFactory.getMayanAdapter(),
105
105
  CrossChainSwapFactory.getRelayAdapter(),
106
+ CrossChainSwapFactory.getNearIntentsAdapter(),
106
107
 
107
108
  // CrossChainSwapFactory.getAcrossAdapter(),
108
109
  // CrossChainSwapFactory.getXyFinanceAdapter(),
109
- // CrossChainSwapFactory.getNearIntentsAdapter(),
110
110
  // CrossChainSwapFactory.getSymbiosisAdapter(),
111
111
  // CrossChainSwapFactory.getDebridgeInstance(),
112
112
  // CrossChainSwapFactory.getLifiInstance(),
@@ -124,8 +124,8 @@ export class CrossChainSwapFactory {
124
124
  return CrossChainSwapFactory.getRelayAdapter()
125
125
  // case 'xyfinance':
126
126
  // return CrossChainSwapFactory.getXyFinanceAdapter()
127
- // case 'near intents':
128
- // return CrossChainSwapFactory.getNearIntentsAdapter()
127
+ case 'near intents':
128
+ return CrossChainSwapFactory.getNearIntentsAdapter()
129
129
  case 'mayan':
130
130
  return CrossChainSwapFactory.getMayanAdapter()
131
131
  // case 'symbiosis':
@@ -6,7 +6,7 @@ import type {
6
6
  } from './adapters/BaseSwapAdapter.js'
7
7
 
8
8
  export interface Quote {
9
- adapter: SwapProvider
9
+ adapter?: SwapProvider
10
10
  quote: NormalizedQuote
11
11
  }
12
12