@shapeshiftoss/swapper 17.6.10 → 17.7.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 (232) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/constants.js +11 -10
  4. package/dist/cjs/cowswap-utils/constants.js +3 -0
  5. package/dist/cjs/cowswap-utils/index.js +6 -0
  6. package/dist/cjs/index.d.ts +1 -1
  7. package/dist/cjs/index.js +1 -1
  8. package/dist/cjs/solana-utils/getUnsignedSolanaTransaction.js +4 -2
  9. package/dist/cjs/swappers/AcrossSwapper/constant.js +2 -0
  10. package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +15 -1
  11. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +12 -1
  12. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.js +9 -0
  13. package/dist/cjs/swappers/BebopSwapper/BebopSwapper.js +2 -0
  14. package/dist/cjs/swappers/BebopSwapper/endpoints.js +35 -2
  15. package/dist/cjs/swappers/BebopSwapper/executeSolanaMessage.d.ts +2 -0
  16. package/dist/cjs/swappers/BebopSwapper/executeSolanaMessage.js +47 -0
  17. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.d.ts +4 -0
  18. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +91 -0
  19. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.d.ts +4 -0
  20. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +88 -0
  21. package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +10 -0
  22. package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -0
  23. package/dist/cjs/swappers/BebopSwapper/types.d.ts +49 -1
  24. package/dist/cjs/swappers/BebopSwapper/types.js +9 -2
  25. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +19 -1
  26. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +86 -1
  27. package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +13 -1
  28. package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.js +47 -1
  29. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +17 -1
  30. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.js +10 -0
  31. package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +10 -0
  32. package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +10 -0
  33. package/dist/cjs/swappers/CetusSwapper/utils/helpers.d.ts +1 -1
  34. package/dist/cjs/swappers/CetusSwapper/utils/helpers.js +1 -1
  35. package/dist/cjs/swappers/ChainflipSwapper/constants.js +7 -3
  36. package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +14 -4
  37. package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +1 -0
  38. package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +17 -0
  39. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +10 -0
  40. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +9 -0
  41. package/dist/cjs/swappers/DebridgeSwapper/DebridgeSwapper.d.ts +2 -0
  42. package/dist/cjs/swappers/DebridgeSwapper/DebridgeSwapper.js +7 -0
  43. package/dist/cjs/swappers/DebridgeSwapper/constant.d.ts +5 -0
  44. package/dist/cjs/swappers/DebridgeSwapper/constant.js +36 -0
  45. package/dist/cjs/swappers/{JupiterSwapper → DebridgeSwapper}/endpoints.d.ts +1 -1
  46. package/dist/cjs/swappers/DebridgeSwapper/endpoints.js +217 -0
  47. package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +31 -0
  48. package/dist/cjs/swappers/DebridgeSwapper/getTradeRate/getTradeRate.js +19 -0
  49. package/dist/cjs/swappers/DebridgeSwapper/index.d.ts +1 -0
  50. package/dist/cjs/swappers/DebridgeSwapper/index.js +5 -0
  51. package/dist/cjs/swappers/{JupiterSwapper/utils/jupiterService.d.ts → DebridgeSwapper/utils/debridgeService.d.ts} +1 -1
  52. package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.js +17 -0
  53. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.d.ts +16 -0
  54. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.js +23 -0
  55. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +20 -0
  56. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.js +29 -0
  57. package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.d.ts +11 -0
  58. package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +367 -0
  59. package/dist/cjs/swappers/DebridgeSwapper/utils/types.d.ts +155 -0
  60. package/dist/cjs/swappers/DebridgeSwapper/utils/types.js +9 -0
  61. package/dist/cjs/swappers/MayachainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +1 -1
  62. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +12 -0
  63. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +12 -0
  64. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
  65. package/dist/cjs/swappers/RelaySwapper/constant.js +7 -10
  66. package/dist/cjs/swappers/RelaySwapper/endpoints.js +1 -1
  67. package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +56 -7
  68. package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +22 -7
  69. package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +12 -1
  70. package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.js +10 -0
  71. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +10 -0
  72. package/dist/cjs/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
  73. package/dist/cjs/swappers/ThorchainSwapper/endpoints.js +2 -0
  74. package/dist/cjs/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
  75. package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.d.ts +1 -1
  76. package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +2 -1
  77. package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.test.js +10 -0
  78. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +9 -0
  79. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +9 -0
  80. package/dist/cjs/swappers/utils/affiliateFee.d.ts +17 -0
  81. package/dist/cjs/swappers/utils/affiliateFee.js +43 -0
  82. package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +57 -4
  83. package/dist/cjs/thorchain-utils/index.d.ts +2 -1
  84. package/dist/cjs/thorchain-utils/index.js +2 -1
  85. package/dist/cjs/thorchain-utils/solana/constants.d.ts +1 -0
  86. package/dist/cjs/thorchain-utils/solana/constants.js +6 -0
  87. package/dist/cjs/thorchain-utils/solana/getSolanaTransactionFees.d.ts +2 -0
  88. package/dist/cjs/thorchain-utils/solana/getSolanaTransactionFees.js +41 -0
  89. package/dist/cjs/thorchain-utils/solana/getThorTxData.d.ts +12 -0
  90. package/dist/cjs/thorchain-utils/solana/getThorTxData.js +14 -0
  91. package/dist/cjs/thorchain-utils/solana/getUnsignedSolanaTransaction.d.ts +3 -0
  92. package/dist/cjs/thorchain-utils/solana/getUnsignedSolanaTransaction.js +64 -0
  93. package/dist/cjs/thorchain-utils/solana/index.d.ts +3 -0
  94. package/dist/cjs/{swappers/JupiterSwapper → thorchain-utils/solana}/index.js +3 -2
  95. package/dist/cjs/tron-utils/getUnsignedTronTransaction.js +16 -0
  96. package/dist/cjs/types.d.ts +47 -11
  97. package/dist/cjs/types.js +1 -1
  98. package/dist/cjs/utils.d.ts +3 -0
  99. package/dist/cjs/utils.js +9 -3
  100. package/dist/esm/.tsbuildinfo +1 -1
  101. package/dist/esm/constants.js +11 -10
  102. package/dist/esm/cowswap-utils/constants.js +3 -0
  103. package/dist/esm/cowswap-utils/index.js +6 -0
  104. package/dist/esm/index.d.ts +1 -1
  105. package/dist/esm/index.js +1 -1
  106. package/dist/esm/solana-utils/getUnsignedSolanaTransaction.js +3 -1
  107. package/dist/esm/swappers/AcrossSwapper/constant.js +4 -2
  108. package/dist/esm/swappers/AcrossSwapper/utils/getTrade.js +15 -1
  109. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +12 -1
  110. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.js +9 -0
  111. package/dist/esm/swappers/BebopSwapper/BebopSwapper.js +2 -0
  112. package/dist/esm/swappers/BebopSwapper/endpoints.js +36 -3
  113. package/dist/esm/swappers/BebopSwapper/executeSolanaMessage.d.ts +2 -0
  114. package/dist/esm/swappers/BebopSwapper/executeSolanaMessage.js +40 -0
  115. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.d.ts +4 -0
  116. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +87 -0
  117. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.d.ts +4 -0
  118. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +84 -0
  119. package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +10 -0
  120. package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -0
  121. package/dist/esm/swappers/BebopSwapper/types.d.ts +49 -1
  122. package/dist/esm/swappers/BebopSwapper/types.js +8 -1
  123. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +19 -1
  124. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +85 -2
  125. package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +13 -1
  126. package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.js +44 -1
  127. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +17 -1
  128. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.js +10 -0
  129. package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +10 -0
  130. package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +10 -0
  131. package/dist/esm/swappers/CetusSwapper/utils/helpers.d.ts +1 -1
  132. package/dist/esm/swappers/CetusSwapper/utils/helpers.js +1 -1
  133. package/dist/esm/swappers/ChainflipSwapper/constants.js +8 -4
  134. package/dist/esm/swappers/ChainflipSwapper/endpoints.js +14 -4
  135. package/dist/esm/swappers/ChainflipSwapper/types.d.ts +1 -0
  136. package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +17 -0
  137. package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +10 -0
  138. package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +9 -0
  139. package/dist/esm/swappers/{JupiterSwapper/JupiterSwapper.d.ts → DebridgeSwapper/DebridgeSwapper.d.ts} +1 -1
  140. package/dist/esm/swappers/DebridgeSwapper/DebridgeSwapper.js +4 -0
  141. package/dist/esm/swappers/DebridgeSwapper/constant.d.ts +5 -0
  142. package/dist/esm/swappers/DebridgeSwapper/constant.js +30 -0
  143. package/dist/esm/swappers/{JupiterSwapper → DebridgeSwapper}/endpoints.d.ts +1 -1
  144. package/dist/esm/swappers/DebridgeSwapper/endpoints.js +211 -0
  145. package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +27 -0
  146. package/dist/esm/swappers/DebridgeSwapper/getTradeRate/getTradeRate.js +15 -0
  147. package/dist/esm/swappers/DebridgeSwapper/index.d.ts +1 -0
  148. package/dist/esm/swappers/DebridgeSwapper/index.js +1 -0
  149. package/dist/esm/swappers/{JupiterSwapper/utils/jupiterService.d.ts → DebridgeSwapper/utils/debridgeService.d.ts} +1 -1
  150. package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.js +11 -0
  151. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.d.ts +16 -0
  152. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.js +19 -0
  153. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +20 -0
  154. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.js +25 -0
  155. package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.d.ts +11 -0
  156. package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.js +360 -0
  157. package/dist/esm/swappers/DebridgeSwapper/utils/types.d.ts +155 -0
  158. package/dist/esm/swappers/DebridgeSwapper/utils/types.js +5 -0
  159. package/dist/esm/swappers/MayachainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +1 -1
  160. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +14 -2
  161. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +14 -2
  162. package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
  163. package/dist/esm/swappers/RelaySwapper/constant.js +9 -12
  164. package/dist/esm/swappers/RelaySwapper/endpoints.js +2 -2
  165. package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +59 -10
  166. package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +22 -7
  167. package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +12 -1
  168. package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.js +10 -0
  169. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +10 -0
  170. package/dist/esm/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
  171. package/dist/esm/swappers/ThorchainSwapper/endpoints.js +3 -1
  172. package/dist/esm/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
  173. package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.d.ts +1 -1
  174. package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +2 -1
  175. package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.test.js +11 -1
  176. package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +9 -0
  177. package/dist/esm/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +9 -0
  178. package/dist/esm/swappers/utils/affiliateFee.d.ts +17 -0
  179. package/dist/esm/swappers/utils/affiliateFee.js +39 -0
  180. package/dist/esm/thorchain-utils/getL1RateOrQuote.js +57 -4
  181. package/dist/esm/thorchain-utils/index.d.ts +2 -1
  182. package/dist/esm/thorchain-utils/index.js +1 -0
  183. package/dist/esm/thorchain-utils/solana/constants.d.ts +1 -0
  184. package/dist/esm/thorchain-utils/solana/constants.js +3 -0
  185. package/dist/esm/thorchain-utils/solana/getSolanaTransactionFees.d.ts +2 -0
  186. package/dist/esm/thorchain-utils/solana/getSolanaTransactionFees.js +37 -0
  187. package/dist/esm/thorchain-utils/solana/getThorTxData.d.ts +12 -0
  188. package/dist/esm/thorchain-utils/solana/getThorTxData.js +10 -0
  189. package/dist/esm/thorchain-utils/solana/getUnsignedSolanaTransaction.d.ts +3 -0
  190. package/dist/esm/thorchain-utils/solana/getUnsignedSolanaTransaction.js +60 -0
  191. package/dist/esm/thorchain-utils/solana/index.d.ts +3 -0
  192. package/dist/esm/thorchain-utils/solana/index.js +3 -0
  193. package/dist/esm/tron-utils/getUnsignedTronTransaction.js +16 -0
  194. package/dist/esm/types.d.ts +47 -11
  195. package/dist/esm/types.js +1 -1
  196. package/dist/esm/utils.d.ts +3 -0
  197. package/dist/esm/utils.js +7 -2
  198. package/package.json +19 -19
  199. package/dist/cjs/swappers/JupiterSwapper/JupiterSwapper.d.ts +0 -2
  200. package/dist/cjs/swappers/JupiterSwapper/JupiterSwapper.js +0 -27
  201. package/dist/cjs/swappers/JupiterSwapper/endpoints.js +0 -15
  202. package/dist/cjs/swappers/JupiterSwapper/errorPatterns.d.ts +0 -15
  203. package/dist/cjs/swappers/JupiterSwapper/errorPatterns.js +0 -29
  204. package/dist/cjs/swappers/JupiterSwapper/idls/referral.d.ts +0 -739
  205. package/dist/cjs/swappers/JupiterSwapper/idls/referral.js +0 -741
  206. package/dist/cjs/swappers/JupiterSwapper/index.d.ts +0 -2
  207. package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +0 -191
  208. package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeRate.js +0 -172
  209. package/dist/cjs/swappers/JupiterSwapper/utils/constants.d.ts +0 -9
  210. package/dist/cjs/swappers/JupiterSwapper/utils/constants.js +0 -14
  211. package/dist/cjs/swappers/JupiterSwapper/utils/helpers.d.ts +0 -56
  212. package/dist/cjs/swappers/JupiterSwapper/utils/helpers.js +0 -178
  213. package/dist/cjs/swappers/JupiterSwapper/utils/jupiterService.js +0 -15
  214. package/dist/esm/swappers/JupiterSwapper/JupiterSwapper.js +0 -24
  215. package/dist/esm/swappers/JupiterSwapper/endpoints.js +0 -12
  216. package/dist/esm/swappers/JupiterSwapper/errorPatterns.d.ts +0 -15
  217. package/dist/esm/swappers/JupiterSwapper/errorPatterns.js +0 -25
  218. package/dist/esm/swappers/JupiterSwapper/idls/referral.d.ts +0 -739
  219. package/dist/esm/swappers/JupiterSwapper/idls/referral.js +0 -738
  220. package/dist/esm/swappers/JupiterSwapper/index.d.ts +0 -2
  221. package/dist/esm/swappers/JupiterSwapper/index.js +0 -2
  222. package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +0 -187
  223. package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeRate.js +0 -168
  224. package/dist/esm/swappers/JupiterSwapper/utils/constants.d.ts +0 -9
  225. package/dist/esm/swappers/JupiterSwapper/utils/constants.js +0 -11
  226. package/dist/esm/swappers/JupiterSwapper/utils/helpers.d.ts +0 -56
  227. package/dist/esm/swappers/JupiterSwapper/utils/helpers.js +0 -169
  228. package/dist/esm/swappers/JupiterSwapper/utils/jupiterService.js +0 -12
  229. /package/dist/cjs/swappers/{JupiterSwapper/swapperApi → DebridgeSwapper/getTradeQuote}/getTradeQuote.d.ts +0 -0
  230. /package/dist/cjs/swappers/{JupiterSwapper/swapperApi → DebridgeSwapper/getTradeRate}/getTradeRate.d.ts +0 -0
  231. /package/dist/esm/swappers/{JupiterSwapper/swapperApi → DebridgeSwapper/getTradeQuote}/getTradeQuote.d.ts +0 -0
  232. /package/dist/esm/swappers/{JupiterSwapper/swapperApi → DebridgeSwapper/getTradeRate}/getTradeRate.d.ts +0 -0
@@ -1,6 +1,7 @@
1
1
  import { KnownChainIds } from '@shapeshiftoss/types';
2
2
  import type { Address, Hex } from 'viem';
3
- export declare const bebopSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet];
3
+ export declare const bebopSupportedEvmChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet];
4
+ export declare const bebopSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.SolanaMainnet];
4
5
  export type BebopSupportedChainId = (typeof bebopSupportedChainIds)[number];
5
6
  export type BebopQuoteRoute = {
6
7
  type: string;
@@ -87,3 +88,50 @@ export type BebopQuoteResponse = {
87
88
  export declare const chainIdToBebopChain: Record<BebopSupportedChainId, string>;
88
89
  export declare const BEBOP_NATIVE_MARKER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
89
90
  export declare const BEBOP_DUMMY_ADDRESS: `0x${string}`;
91
+ export declare const BEBOP_SOLANA_DUMMY_ADDRESS = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
92
+ export type BebopSolanaQuoteResponse = {
93
+ requestId: string;
94
+ type: string;
95
+ status: 'QUOTE_SUCCESS' | 'QUOTE_INDIC_ROUTE';
96
+ quoteId: string;
97
+ chainId: number;
98
+ approvalType: string;
99
+ nativeToken: string;
100
+ taker: string;
101
+ receiver: string;
102
+ expiry: number;
103
+ slippage: number;
104
+ gasFee: {
105
+ native: string;
106
+ usd: number;
107
+ };
108
+ buyTokens: Record<string, {
109
+ amount: string;
110
+ decimals: number;
111
+ priceUsd: number;
112
+ symbol: string;
113
+ minimumAmount: string;
114
+ price: number;
115
+ priceBeforeFee: number;
116
+ amountBeforeFee: string;
117
+ deltaFromExpected: number;
118
+ }>;
119
+ sellTokens: Record<string, {
120
+ amount: string;
121
+ decimals: number;
122
+ priceUsd: number;
123
+ symbol: string;
124
+ price: number;
125
+ priceBeforeFee: number;
126
+ }>;
127
+ settlementAddress: string;
128
+ approvalTarget: string;
129
+ requiredSignatures: string[];
130
+ priceImpact: number;
131
+ warnings: string[];
132
+ solana_tx: string;
133
+ blockhash: string;
134
+ makers: string[];
135
+ partnerFee?: Record<string, string>;
136
+ protocolFee?: Record<string, string>;
137
+ };
@@ -1,5 +1,5 @@
1
1
  import { KnownChainIds } from '@shapeshiftoss/types';
2
- export const bebopSupportedChainIds = [
2
+ export const bebopSupportedEvmChainIds = [
3
3
  KnownChainIds.EthereumMainnet,
4
4
  KnownChainIds.PolygonMainnet,
5
5
  KnownChainIds.ArbitrumMainnet,
@@ -8,6 +8,10 @@ export const bebopSupportedChainIds = [
8
8
  KnownChainIds.OptimismMainnet,
9
9
  KnownChainIds.BnbSmartChainMainnet,
10
10
  ];
11
+ export const bebopSupportedChainIds = [
12
+ ...bebopSupportedEvmChainIds,
13
+ KnownChainIds.SolanaMainnet,
14
+ ];
11
15
  export const chainIdToBebopChain = {
12
16
  [KnownChainIds.EthereumMainnet]: 'ethereum',
13
17
  [KnownChainIds.PolygonMainnet]: 'polygon',
@@ -16,9 +20,12 @@ export const chainIdToBebopChain = {
16
20
  [KnownChainIds.AvalancheMainnet]: 'avalanche',
17
21
  [KnownChainIds.OptimismMainnet]: 'optimism',
18
22
  [KnownChainIds.BnbSmartChainMainnet]: 'bsc',
23
+ [KnownChainIds.SolanaMainnet]: 'solana',
19
24
  };
20
25
  export const BEBOP_NATIVE_MARKER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
21
26
  // Dummy address used for rate quotes when no wallet is connected.
22
27
  // This is Vitalik's address, same as what Bebop's own UI uses for price-only quotes.
23
28
  // MUST NEVER be used for executable quote transactions.
24
29
  export const BEBOP_DUMMY_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
30
+ // Solana dummy address for rate quotes - uses the Token Program address which cannot be a real wallet
31
+ export const BEBOP_SOLANA_DUMMY_ADDRESS = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
@@ -2,7 +2,7 @@ import type { Asset } from '@shapeshiftoss/types';
2
2
  import type { Result } from '@sniptt/monads';
3
3
  import type { Address } from 'viem';
4
4
  import type { SwapErrorRight } from '../../../types.js';
5
- import type { BebopQuoteResponse } from '../types.js';
5
+ import type { BebopQuoteResponse, BebopSolanaQuoteResponse } from '../types.js';
6
6
  export declare const fetchBebopQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }: {
7
7
  buyAsset: Asset;
8
8
  sellAsset: Asset;
@@ -21,3 +21,21 @@ export declare const fetchBebopPrice: ({ buyAsset, sellAsset, sellAmountIncludin
21
21
  affiliateBps?: string | undefined;
22
22
  apiKey: string;
23
23
  }) => Promise<Result<BebopQuoteResponse, SwapErrorRight>>;
24
+ export declare const fetchBebopSolanaQuote: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }: {
25
+ buyAsset: Asset;
26
+ sellAsset: Asset;
27
+ sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
28
+ takerAddress: string;
29
+ receiverAddress: string;
30
+ slippageTolerancePercentageDecimal: string;
31
+ affiliateBps?: string | undefined;
32
+ apiKey: string;
33
+ }) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
34
+ export declare const fetchBebopSolanaPrice: ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }: {
35
+ buyAsset: Asset;
36
+ sellAsset: Asset;
37
+ sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
38
+ receiveAddress: string | undefined;
39
+ affiliateBps?: string | undefined;
40
+ apiKey: string;
41
+ }) => Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>>;
@@ -3,9 +3,9 @@ import { Err, Ok } from '@sniptt/monads';
3
3
  import { getAddress } from 'viem';
4
4
  import { TradeQuoteError } from '../../../types.js';
5
5
  import { makeSwapErrorRight } from '../../../utils.js';
6
- import { BEBOP_DUMMY_ADDRESS, chainIdToBebopChain } from '../types.js';
6
+ import { BEBOP_DUMMY_ADDRESS, BEBOP_SOLANA_DUMMY_ADDRESS, chainIdToBebopChain } from '../types.js';
7
7
  import { bebopServiceFactory } from './bebopService.js';
8
- import { assetIdToBebopToken } from './helpers/helpers.js';
8
+ import { assetIdToBebopSolanaToken, assetIdToBebopToken } from './helpers/helpers.js';
9
9
  export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
10
10
  try {
11
11
  const sellToken = assetIdToBebopToken(sellAsset.assetId);
@@ -86,3 +86,86 @@ export const fetchBebopPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtoc
86
86
  apiKey,
87
87
  });
88
88
  };
89
+ export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
90
+ try {
91
+ const sellToken = assetIdToBebopSolanaToken(sellAsset.assetId);
92
+ const buyToken = assetIdToBebopSolanaToken(buyAsset.assetId);
93
+ const sellAmountFormatted = bn(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
94
+ const slippagePercentage = bn(slippageTolerancePercentageDecimal ?? 0.003)
95
+ .times(100)
96
+ .toNumber();
97
+ const url = 'https://api.bebop.xyz/pmm/solana/v3/quote';
98
+ const params = new URLSearchParams({
99
+ sell_tokens: sellToken,
100
+ buy_tokens: buyToken,
101
+ sell_amounts: sellAmountFormatted,
102
+ taker_address: takerAddress,
103
+ receiver_address: receiverAddress,
104
+ slippage: slippagePercentage.toString(),
105
+ approval_type: 'Standard',
106
+ skip_validation: 'false',
107
+ gasless: 'true',
108
+ source: 'shapeshift',
109
+ });
110
+ if (affiliateBps && affiliateBps !== '0') {
111
+ params.set('fee', affiliateBps);
112
+ }
113
+ const bebopService = bebopServiceFactory({ apiKey });
114
+ const maybeResponse = await bebopService.get(`${url}?${params}`);
115
+ if (maybeResponse.isErr()) {
116
+ const err = maybeResponse.unwrapErr();
117
+ return Err(makeSwapErrorRight({
118
+ message: 'Failed to fetch quote from Bebop Solana',
119
+ cause: err.cause,
120
+ code: TradeQuoteError.QueryFailed,
121
+ }));
122
+ }
123
+ const response = maybeResponse.unwrap();
124
+ if (response.data.status !== 'QUOTE_SUCCESS') {
125
+ return Err(makeSwapErrorRight({
126
+ message: `Bebop Solana quote not executable: ${response.data.status}`,
127
+ code: TradeQuoteError.InvalidResponse,
128
+ }));
129
+ }
130
+ if (!response.data.solana_tx) {
131
+ return Err(makeSwapErrorRight({
132
+ message: 'Missing solana_tx in response',
133
+ code: TradeQuoteError.InvalidResponse,
134
+ }));
135
+ }
136
+ // Reject routes containing ANY AMM/CLMM makers - these produce malformed txs
137
+ // (wrong signature count in wire format) and require pre-existing ATAs that
138
+ // Bebop's gasless co-signed flow can't create. This includes mixed routes
139
+ // like ["raydium clmm-rfqm", "🦊"] where Bebop serializes the tx with fewer
140
+ // signature slots than the message header requires.
141
+ // When rejected, other swappers like Jupiter will handle these pairs instead.
142
+ const hasAmmRoute = response.data.makers.some(maker => maker.toLowerCase().includes('clmm') || maker.toLowerCase().includes('amm'));
143
+ if (hasAmmRoute) {
144
+ return Err(makeSwapErrorRight({
145
+ message: `Bebop Solana quote contains AMM routing (${response.data.makers.join(', ')}), which produces malformed txs`,
146
+ code: TradeQuoteError.NoRouteFound,
147
+ }));
148
+ }
149
+ return Ok(response.data);
150
+ }
151
+ catch (error) {
152
+ return Err(makeSwapErrorRight({
153
+ message: 'Unexpected error fetching Bebop Solana quote',
154
+ cause: error,
155
+ code: TradeQuoteError.QueryFailed,
156
+ }));
157
+ }
158
+ };
159
+ export const fetchBebopSolanaPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
160
+ const address = receiveAddress || BEBOP_SOLANA_DUMMY_ADDRESS;
161
+ return fetchBebopSolanaQuote({
162
+ buyAsset,
163
+ sellAsset,
164
+ sellAmountIncludingProtocolFeesCryptoBaseUnit,
165
+ takerAddress: address,
166
+ receiverAddress: address,
167
+ slippageTolerancePercentageDecimal: '0.01',
168
+ affiliateBps,
169
+ apiKey,
170
+ });
171
+ };
@@ -1,11 +1,23 @@
1
1
  import type { AssetId, ChainId } from '@shapeshiftoss/caip';
2
2
  import type { Asset } from '@shapeshiftoss/types';
3
+ export declare const isSolanaChainId: (chainId: ChainId) => boolean;
3
4
  export declare const assetIdToBebopToken: (assetId: AssetId) => string;
4
- export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet | import("@shapeshiftoss/types").KnownChainIds.BnbSmartChainMainnet | import("@shapeshiftoss/types").KnownChainIds.PolygonMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BaseMainnet;
5
+ export declare const assetIdToBebopSolanaToken: (assetId: AssetId) => string;
6
+ export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.AvalancheMainnet | import("@shapeshiftoss/types").KnownChainIds.OptimismMainnet | import("@shapeshiftoss/types").KnownChainIds.BnbSmartChainMainnet | import("@shapeshiftoss/types").KnownChainIds.PolygonMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BaseMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet;
5
7
  export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
6
8
  buyAsset: Asset;
7
9
  sellAsset: Asset;
8
10
  }) => import("@sniptt/monads/build/result/result").ResErr<unknown, import("../../../../types.js").SwapErrorRight> | import("@sniptt/monads/build/result/result").ResOk<boolean, never>;
11
+ /**
12
+ * Bebop's /order endpoint has a bug where it hardcodes the taker signature placement
13
+ * at the last signer index. When the taker's pubkey bytes sort before the maker's,
14
+ * the taker ends up at an earlier index, and Bebop places the sig in the wrong slot.
15
+ * This causes ghost txs (order returns "Success" but tx silently fails on-chain).
16
+ *
17
+ * Returns true if the taker is at the expected index (safe to execute), false otherwise.
18
+ * Returns false on decode failure.
19
+ */
20
+ export declare const isBebopSolanaTxSafe: (solanaTxBase64: string, takerAddress: string) => boolean;
9
21
  export declare const calculateRate: ({ buyAmount, sellAmount, buyAsset, sellAsset, }: {
10
22
  buyAmount: string;
11
23
  sellAmount: string;
@@ -1,16 +1,27 @@
1
- import { fromAssetId } from '@shapeshiftoss/caip';
1
+ import { fromAssetId, solanaChainId } from '@shapeshiftoss/caip';
2
2
  import { bn, convertPrecision, isToken } from '@shapeshiftoss/utils';
3
3
  import { Err, Ok } from '@sniptt/monads';
4
+ import { PublicKey, VersionedTransaction } from '@solana/web3.js';
4
5
  import { getAddress } from 'viem';
5
6
  import { TradeQuoteError } from '../../../../types.js';
6
7
  import { makeSwapErrorRight } from '../../../../utils.js';
7
8
  import { BEBOP_NATIVE_MARKER, bebopSupportedChainIds } from '../../types.js';
9
+ export const isSolanaChainId = (chainId) => {
10
+ return chainId === solanaChainId;
11
+ };
8
12
  export const assetIdToBebopToken = (assetId) => {
9
13
  if (!isToken(assetId))
10
14
  return BEBOP_NATIVE_MARKER;
11
15
  const { assetReference } = fromAssetId(assetId);
12
16
  return getAddress(assetReference);
13
17
  };
18
+ export const assetIdToBebopSolanaToken = (assetId) => {
19
+ const { assetReference, chainId } = fromAssetId(assetId);
20
+ if (chainId === solanaChainId && !isToken(assetId)) {
21
+ return 'So11111111111111111111111111111111111111112';
22
+ }
23
+ return assetReference;
24
+ };
14
25
  export const isSupportedChainId = (chainId) => {
15
26
  return bebopSupportedChainIds.includes(chainId);
16
27
  };
@@ -40,6 +51,38 @@ export const assertValidTrade = ({ buyAsset, sellAsset, }) => {
40
51
  }
41
52
  return Ok(true);
42
53
  };
54
+ /**
55
+ * Bebop's /order endpoint has a bug where it hardcodes the taker signature placement
56
+ * at the last signer index. When the taker's pubkey bytes sort before the maker's,
57
+ * the taker ends up at an earlier index, and Bebop places the sig in the wrong slot.
58
+ * This causes ghost txs (order returns "Success" but tx silently fails on-chain).
59
+ *
60
+ * Returns true if the taker is at the expected index (safe to execute), false otherwise.
61
+ * Returns false on decode failure.
62
+ */
63
+ export const isBebopSolanaTxSafe = (solanaTxBase64, takerAddress) => {
64
+ try {
65
+ const tx = VersionedTransaction.deserialize(Buffer.from(solanaTxBase64, 'base64'));
66
+ const numSigners = tx.message.header.numRequiredSignatures;
67
+ if (numSigners < 1) {
68
+ console.warn('[Bebop Solana] Transaction has no required signers. Rejecting as malformed.');
69
+ return false;
70
+ }
71
+ const signerKeys = tx.message.staticAccountKeys.slice(0, numSigners);
72
+ const takerPubkey = new PublicKey(takerAddress);
73
+ const takerIndex = signerKeys.findIndex(key => key.equals(takerPubkey));
74
+ const expectedIndex = numSigners - 1; // Bebop hardcodes to last signer slot
75
+ if (takerIndex !== expectedIndex) {
76
+ console.warn(`[Bebop Solana] Taker signer index ${takerIndex}, expected ${expectedIndex}. Rejecting to avoid ghost tx.`);
77
+ return false;
78
+ }
79
+ return true;
80
+ }
81
+ catch (e) {
82
+ console.error(`[Bebop Solana] Failed to decode tx for signer check: ${e.message}`);
83
+ return false;
84
+ }
85
+ };
43
86
  export const calculateRate = ({ buyAmount, sellAmount, buyAsset, sellAsset, }) => {
44
87
  return convertPrecision({
45
88
  value: buyAmount,
@@ -6,6 +6,7 @@ import { AddressLookupTableAccount, PublicKey, TransactionMessage, VersionedTran
6
6
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
7
7
  import { SwapperName, TradeQuoteError } from '../../../types.js';
8
8
  import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
9
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
9
10
  import { makeButterSwapAffiliate } from '../utils/constants.js';
10
11
  import { ButterSwapErrorCode, butterSwapErrorToTradeQuoteError, fetchTxData, getButterRoute, isBuildTxSuccess, isRouteSuccess, } from '../xhr.js';
11
12
  export const getTradeQuote = async (input, _deps) => {
@@ -122,7 +123,12 @@ export const getTradeQuote = async (input, _deps) => {
122
123
  if (sellAsset.chainId !== solanaChainId)
123
124
  return Ok(undefined);
124
125
  const txData = buildTx.data.startsWith('0x') ? buildTx.data.slice(2) : buildTx.data;
125
- const versionedTransaction = VersionedTransaction.deserialize(new Uint8Array(Buffer.from(txData, 'hex')));
126
+ const txBytes = Buffer.from(txData, 'hex');
127
+ // Solana transactions are limited to 1232 bytes. If Butter returns a larger tx,
128
+ // we need to split it into a Jito bundle (2 txs with tip in the last one).
129
+ const SOLANA_TX_SIZE_LIMIT = 1232;
130
+ const isOversized = txBytes.length > SOLANA_TX_SIZE_LIMIT;
131
+ const versionedTransaction = VersionedTransaction.deserialize(new Uint8Array(txBytes));
126
132
  const adapter = _deps.assertGetSolanaChainAdapter(sellAsset.chainId);
127
133
  try {
128
134
  const addressLookupTableAccountKeys = versionedTransaction.message.addressTableLookups.map(lookup => lookup.accountKey.toString());
@@ -141,6 +147,7 @@ export const getTradeQuote = async (input, _deps) => {
141
147
  return Ok({
142
148
  instructions,
143
149
  addressLookupTableAddresses: addressLookupTableAccountKeys,
150
+ isOversized,
144
151
  });
145
152
  }
146
153
  catch (error) {
@@ -184,6 +191,15 @@ export const getTradeQuote = async (input, _deps) => {
184
191
  ...(solanaTransactionMetadata && {
185
192
  solanaTransactionMetadata,
186
193
  }),
194
+ affiliateFee: buildAffiliateFee({
195
+ strategy: 'buy_asset',
196
+ affiliateBps,
197
+ sellAsset,
198
+ buyAsset,
199
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
200
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
201
+ isEstimate: true,
202
+ }),
187
203
  };
188
204
  const tradeQuote = {
189
205
  id: route.hash,
@@ -5,6 +5,7 @@ import { Err, Ok } from '@sniptt/monads';
5
5
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
6
6
  import { SwapperName, TradeQuoteError } from '../../../types.js';
7
7
  import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
8
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
8
9
  import { makeButterSwapAffiliate } from '../utils/constants.js';
9
10
  import { ButterSwapErrorCode, butterSwapErrorToTradeQuoteError, getButterRoute, isRouteSuccess, } from '../xhr.js';
10
11
  export const getTradeRate = async (input, _deps) => {
@@ -107,6 +108,15 @@ export const getTradeRate = async (input, _deps) => {
107
108
  accountNumber,
108
109
  allowanceContract: route.contract ?? '0x0',
109
110
  estimatedExecutionTimeMs: route.timeEstimated * 1000,
111
+ affiliateFee: buildAffiliateFee({
112
+ strategy: 'buy_asset',
113
+ affiliateBps,
114
+ sellAsset,
115
+ buyAsset,
116
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
117
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
118
+ isEstimate: true,
119
+ }),
110
120
  };
111
121
  const tradeRate = {
112
122
  id: route.hash,
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
5
5
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
6
6
  import { SwapperName, TradeQuoteError } from '../../../types.js';
7
7
  import { makeSwapErrorRight } from '../../../utils.js';
8
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
8
9
  import { getAggregatorClient, getSuiClient } from '../utils/helpers.js';
9
10
  import { getCetusTradeData } from './getCetusTradeData.js';
10
11
  export const getTradeQuote = async (input, deps) => {
@@ -78,6 +79,15 @@ export const getTradeQuote = async (input, deps) => {
78
79
  sellAsset,
79
80
  allowanceContract: '0x0',
80
81
  estimatedExecutionTimeMs: undefined,
82
+ affiliateFee: buildAffiliateFee({
83
+ strategy: 'buy_asset',
84
+ affiliateBps,
85
+ sellAsset,
86
+ buyAsset,
87
+ sellAmountCryptoBaseUnit: sellAmount,
88
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
89
+ isEstimate: true,
90
+ }),
81
91
  },
82
92
  ],
83
93
  };
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
5
5
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
6
6
  import { SwapperName, TradeQuoteError } from '../../../types.js';
7
7
  import { makeSwapErrorRight } from '../../../utils.js';
8
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
8
9
  import { getAggregatorClient, getSuiClient } from '../utils/helpers.js';
9
10
  import { getCetusTradeData } from './getCetusTradeData.js';
10
11
  export const getTradeRate = async (input, deps) => {
@@ -76,6 +77,15 @@ export const getTradeRate = async (input, deps) => {
76
77
  sellAsset,
77
78
  allowanceContract: '0x0',
78
79
  estimatedExecutionTimeMs: undefined,
80
+ affiliateFee: buildAffiliateFee({
81
+ strategy: 'buy_asset',
82
+ affiliateBps,
83
+ sellAsset,
84
+ buyAsset,
85
+ sellAmountCryptoBaseUnit: sellAmount,
86
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
87
+ isEstimate: true,
88
+ }),
79
89
  },
80
90
  ],
81
91
  };
@@ -1,6 +1,6 @@
1
1
  import type { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
2
2
  import { AggregatorClient } from '@cetusprotocol/aggregator-sdk';
3
- import { SuiClient } from '@cetusprotocol/aggregator-sdk/node_modules/@mysten/sui/client';
3
+ import { SuiClient } from '@mysten/sui/client';
4
4
  import type { Asset } from '@shapeshiftoss/types';
5
5
  export declare const getAggregatorClient: (rpcUrl: string) => AggregatorClient;
6
6
  export declare const getSuiClient: (rpcUrl: string) => SuiClient;
@@ -1,5 +1,5 @@
1
1
  import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
2
- import { SuiClient } from '@cetusprotocol/aggregator-sdk/node_modules/@mysten/sui/client';
2
+ import { SuiClient } from '@mysten/sui/client';
3
3
  import { fromAssetId } from '@shapeshiftoss/caip';
4
4
  let suiClientInstance;
5
5
  let aggregatorClientInstance;
@@ -1,4 +1,4 @@
1
- import { arbitrumAssetId, btcAssetId, ethAssetId, flipAssetId, solAssetId, usdcAssetId, usdcOnArbitrumOneAssetId, usdcOnSolanaAssetId, usdtAssetId, } from '@shapeshiftoss/caip';
1
+ import { arbitrumAssetId, btcAssetId, ethAssetId, flipAssetId, solAssetId, usdcAssetId, usdcOnArbitrumOneAssetId, usdcOnSolanaAssetId, usdtAssetId, usdtOnArbitrumOneAssetId, usdtOnSolanaAssetId, wbtcAssetId, } from '@shapeshiftoss/caip';
2
2
  import { KnownChainIds } from '@shapeshiftoss/types';
3
3
  import { SwapperName } from '../../types.js';
4
4
  import { ChainflipNetwork } from './types.js';
@@ -11,10 +11,14 @@ export const ChainflipSupportedChainIds = [
11
11
  KnownChainIds.SolanaMainnet,
12
12
  ];
13
13
  export const ChainflipSupportedAssetIdsByChainId = {
14
- [KnownChainIds.EthereumMainnet]: [ethAssetId, flipAssetId, usdcAssetId, usdtAssetId],
15
- [KnownChainIds.ArbitrumMainnet]: [arbitrumAssetId, usdcOnArbitrumOneAssetId],
14
+ [KnownChainIds.EthereumMainnet]: [ethAssetId, flipAssetId, usdcAssetId, usdtAssetId, wbtcAssetId],
15
+ [KnownChainIds.ArbitrumMainnet]: [
16
+ arbitrumAssetId,
17
+ usdcOnArbitrumOneAssetId,
18
+ usdtOnArbitrumOneAssetId,
19
+ ],
16
20
  [KnownChainIds.BitcoinMainnet]: [btcAssetId],
17
- [KnownChainIds.SolanaMainnet]: [solAssetId, usdcOnSolanaAssetId],
21
+ [KnownChainIds.SolanaMainnet]: [solAssetId, usdcOnSolanaAssetId, usdtOnSolanaAssetId],
18
22
  };
19
23
  export const chainIdToChainflipNetwork = {
20
24
  [KnownChainIds.EthereumMainnet]: ChainflipNetwork.Ethereum,
@@ -123,6 +123,9 @@ export const chainflipApi = {
123
123
  value,
124
124
  chainSpecific: { from, tokenId },
125
125
  });
126
+ // Chainflip deposit addresses are program-owned accounts that require more compute
127
+ // than a regular SOL transfer. Apply a safety margin to avoid "Computational budget exceeded".
128
+ const computeUnits = Math.ceil(Math.max(Number(fast.chainSpecific.computeUnits), 50_000) * 1.6);
126
129
  return adapter.buildSendApiTransaction({
127
130
  to,
128
131
  from,
@@ -130,7 +133,7 @@ export const chainflipApi = {
130
133
  accountNumber,
131
134
  chainSpecific: {
132
135
  tokenId,
133
- computeUnitLimit: fast.chainSpecific.computeUnits,
136
+ computeUnitLimit: String(computeUnits),
134
137
  computeUnitPrice: fast.chainSpecific.priorityFee,
135
138
  },
136
139
  });
@@ -153,11 +156,16 @@ export const chainflipApi = {
153
156
  tokenId: contractAddressOrUndefined(sellAsset.assetId),
154
157
  },
155
158
  });
156
- return fast.txFee;
159
+ // Mirror the same compute budget boost as getUnsignedSolanaTransaction
160
+ // to avoid underquoting fees for Chainflip deposit addresses
161
+ const simulatedUnits = Number(fast.chainSpecific.computeUnits);
162
+ const boostedUnits = Math.ceil(Math.max(simulatedUnits, 50_000) * 1.6);
163
+ const ratio = simulatedUnits > 0 ? boostedUnits / simulatedUnits : 1;
164
+ return String(Math.ceil(Number(fast.txFee) * ratio));
157
165
  },
158
166
  checkTradeStatus: async ({ config, swap }) => {
159
167
  const chainflipSwapId = swap?.metadata.chainflipSwapId;
160
- if (!chainflipSwapId)
168
+ if (chainflipSwapId == null)
161
169
  throw Error(`chainflipSwapId is required`);
162
170
  const brokerUrl = config.VITE_CHAINFLIP_API_URL;
163
171
  const apiKey = config.VITE_CHAINFLIP_API_KEY;
@@ -171,13 +179,14 @@ export const chainflipApi = {
171
179
  };
172
180
  }
173
181
  const { data: statusResponse } = maybeStatusResponse.unwrap();
174
- const { status: { swapEgress }, } = statusResponse;
182
+ const { status: { swapEgress, swapId }, } = statusResponse;
175
183
  // Assume no outbound Tx is a pending Tx
176
184
  if (!swapEgress?.transactionReference) {
177
185
  return {
178
186
  buyTxHash: undefined,
179
187
  status: TxStatus.Pending,
180
188
  message: getLatestChainflipStatusMessage(statusResponse),
189
+ chainflipSwapId: swapId ?? undefined,
181
190
  };
182
191
  }
183
192
  // Assume as soon as we have an outbound Tx, the swap is complete.
@@ -186,6 +195,7 @@ export const chainflipApi = {
186
195
  buyTxHash: swapEgress.transactionReference,
187
196
  status: TxStatus.Confirmed,
188
197
  message: undefined,
198
+ chainflipSwapId: swapId ?? undefined,
189
199
  };
190
200
  },
191
201
  };
@@ -3,6 +3,7 @@ import type { ChainflipBaasStatusSwap } from './models/ChainflipBaasStatusSwap.j
3
3
  export type ChainFlipStatus = {
4
4
  status: {
5
5
  state: 'waiting' | 'receiving' | 'swapping' | 'sending' | 'sent' | 'completed' | 'failed';
6
+ swapId?: string;
6
7
  swap?: ChainflipBaasStatusSwap;
7
8
  swapEgress?: ChainflipBaasStatusEgress;
8
9
  };
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
5
5
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
6
6
  import { SwapperName, TradeQuoteError } from '../../../types.js';
7
7
  import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
8
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
8
9
  import { CHAINFLIP_BOOST_SWAP_SOURCE, CHAINFLIP_DCA_BOOST_SWAP_SOURCE, CHAINFLIP_DCA_QUOTE, CHAINFLIP_DCA_SWAP_SOURCE, CHAINFLIP_REGULAR_QUOTE, CHAINFLIP_SWAP_SOURCE, usdcAsset, } from '../constants.js';
9
10
  import { chainflipService } from './chainflipService.js';
10
11
  import { getEvmTxFees } from './getEvmTxFees.js';
@@ -239,6 +240,14 @@ export const getQuoteOrRate = async (input, deps) => {
239
240
  : undefined,
240
241
  chainflipMaxBoostFee: getMaxBoostFee(),
241
242
  },
243
+ affiliateFee: buildAffiliateFee({
244
+ strategy: 'buy_asset',
245
+ affiliateBps: commissionBps,
246
+ sellAsset,
247
+ buyAsset,
248
+ sellAmountCryptoBaseUnit: singleQuoteResponse.boostQuote.ingressAmountNative,
249
+ buyAmountCryptoBaseUnit: singleQuoteResponse.boostQuote.egressAmountNative,
250
+ }),
242
251
  },
243
252
  ],
244
253
  };
@@ -290,6 +299,14 @@ export const getQuoteOrRate = async (input, deps) => {
290
299
  : undefined,
291
300
  chainflipMaxBoostFee: 0,
292
301
  },
302
+ affiliateFee: buildAffiliateFee({
303
+ strategy: 'buy_asset',
304
+ affiliateBps: commissionBps,
305
+ sellAsset,
306
+ buyAsset,
307
+ sellAmountCryptoBaseUnit: singleQuoteResponse.ingressAmountNative ?? '0',
308
+ buyAmountCryptoBaseUnit: singleQuoteResponse.egressAmountNative ?? '0',
309
+ }),
293
310
  },
294
311
  ],
295
312
  };
@@ -8,6 +8,7 @@ import { getAffiliateAppDataFragmentByChainId, getCowNetwork, getFullAppData, }
8
8
  import { COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS, COW_SWAP_VAULT_RELAYER_ADDRESS, SUPPORTED_CHAIN_IDS, } from '../../../cowswap-utils/constants.js';
9
9
  import { SwapperName, TradeQuoteError } from '../../../types.js';
10
10
  import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
11
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
11
12
  import { isNativeEvmAsset } from '../../utils/helpers/helpers.js';
12
13
  import { cowService } from '../utils/cowService.js';
13
14
  import { assertValidTrade, getNowPlusThirtyMinutesTimestamp, getValuesFromQuoteResponse, } from '../utils/helpers/helpers.js';
@@ -113,6 +114,15 @@ export async function getCowSwapTradeQuote(input, config) {
113
114
  buyAmountBeforeFeesCryptoBaseUnit,
114
115
  buyAmountAfterFeesCryptoBaseUnit,
115
116
  source: SwapperName.CowSwap,
117
+ affiliateFee: buildAffiliateFee({
118
+ strategy: 'buy_asset',
119
+ affiliateBps,
120
+ sellAsset,
121
+ buyAsset,
122
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
123
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
124
+ isEstimate: true,
125
+ }),
116
126
  buyAsset,
117
127
  sellAsset,
118
128
  accountNumber,
@@ -8,6 +8,7 @@ import { getAffiliateAppDataFragmentByChainId, getCowNetwork, getFullAppData, }
8
8
  import { COW_SWAP_NATIVE_ASSET_MARKER_ADDRESS, COW_SWAP_VAULT_RELAYER_ADDRESS, SUPPORTED_CHAIN_IDS, } from '../../../cowswap-utils/constants.js';
9
9
  import { SwapperName, TradeQuoteError } from '../../../types.js';
10
10
  import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
11
+ import { buildAffiliateFee } from '../../utils/affiliateFee.js';
11
12
  import { isNativeEvmAsset } from '../../utils/helpers/helpers.js';
12
13
  import { cowService } from '../utils/cowService.js';
13
14
  import { assertValidTrade, getNowPlusThirtyMinutesTimestamp, getValuesFromQuoteResponse, } from '../utils/helpers/helpers.js';
@@ -113,6 +114,14 @@ export async function getCowSwapTradeRate(input, config) {
113
114
  buyAmountBeforeFeesCryptoBaseUnit,
114
115
  buyAmountAfterFeesCryptoBaseUnit,
115
116
  source: SwapperName.CowSwap,
117
+ affiliateFee: buildAffiliateFee({
118
+ strategy: 'buy_asset',
119
+ affiliateBps,
120
+ sellAsset,
121
+ buyAsset,
122
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
123
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
124
+ }),
116
125
  buyAsset,
117
126
  sellAsset,
118
127
  accountNumber,
@@ -1,2 +1,2 @@
1
1
  import type { Swapper } from '../../types.js';
2
- export declare const jupiterSwapper: Swapper;
2
+ export declare const debridgeSwapper: Swapper;
@@ -0,0 +1,4 @@
1
+ import { executeEvmTransaction } from '../../utils.js';
2
+ export const debridgeSwapper = {
3
+ executeEvmTransaction,
4
+ };