@shapeshiftoss/swapper 17.7.2 → 17.8.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 (254) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/constants.js +35 -26
  3. package/dist/cjs/index.d.ts +1 -0
  4. package/dist/cjs/index.js +8 -17
  5. package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
  6. package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +2 -1
  7. package/dist/cjs/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
  8. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +2 -2
  9. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
  10. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeRate/getTradeRate.js +2 -1
  11. package/dist/cjs/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
  12. package/dist/cjs/swappers/AvnuSwapper/endpoints.js +2 -2
  13. package/dist/cjs/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
  14. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +2 -1
  15. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +11 -6
  16. package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +4 -11
  17. package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +12 -15
  18. package/dist/cjs/swappers/BebopSwapper/types.d.ts +65 -79
  19. package/dist/cjs/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
  20. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -18
  21. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +49 -82
  22. package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
  23. package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
  24. package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.js +8 -0
  25. package/dist/cjs/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
  26. package/dist/cjs/swappers/BobGatewaySwapper/endpoints.js +143 -0
  27. package/dist/cjs/swappers/BobGatewaySwapper/index.d.ts +3 -0
  28. package/dist/cjs/swappers/BobGatewaySwapper/index.js +22 -0
  29. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
  30. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +90 -0
  31. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
  32. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +73 -0
  33. package/dist/cjs/swappers/BobGatewaySwapper/types.d.ts +20 -0
  34. package/dist/cjs/swappers/BobGatewaySwapper/types.js +2 -0
  35. package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
  36. package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.js +31 -0
  37. package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
  38. package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.js +314 -0
  39. package/dist/cjs/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +9 -19
  40. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
  41. package/dist/cjs/swappers/ButterSwap/test-data/routeQuote.js +4 -4
  42. package/dist/cjs/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
  43. package/dist/cjs/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
  44. package/dist/cjs/swappers/ButterSwap/xhr.js +4 -4
  45. package/dist/cjs/swappers/CetusSwapper/utils/constants.d.ts +1 -1
  46. package/dist/cjs/swappers/ChainflipSwapper/ChainflipSwapper.js +1 -0
  47. package/dist/cjs/swappers/ChainflipSwapper/constants.d.ts +1 -1
  48. package/dist/cjs/swappers/ChainflipSwapper/constants.js +3 -0
  49. package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +20 -0
  50. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteBoostQuote.js +5 -4
  51. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteEstimatedDurationsSeconds.js +5 -4
  52. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuote.js +5 -5
  53. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuoteFee.js +5 -5
  54. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusChunkInfo.js +5 -4
  55. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusDca.js +5 -4
  56. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusEgress.js +5 -4
  57. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusSwap.js +5 -4
  58. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasSwapDepositAddress.js +5 -4
  59. package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +2 -1
  60. package/dist/cjs/swappers/ChainflipSwapper/types.js +1 -0
  61. package/dist/cjs/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
  62. package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +25 -5
  63. package/dist/cjs/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
  64. package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
  65. package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.js +2 -1
  66. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +3 -2
  67. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
  68. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +3 -2
  69. package/dist/cjs/swappers/CowSwapper/utils/cowService.d.ts +3 -3
  70. package/dist/cjs/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
  71. package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
  72. package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +2 -1
  73. package/dist/cjs/swappers/NearIntentsSwapper/constants.d.ts +1 -0
  74. package/dist/cjs/swappers/NearIntentsSwapper/constants.js +2 -1
  75. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +5 -2
  76. package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
  77. package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
  78. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +2 -1
  79. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +4 -3
  80. package/dist/cjs/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
  81. package/dist/cjs/swappers/RelaySwapper/constant.d.ts +1 -39
  82. package/dist/cjs/swappers/RelaySwapper/constant.js +1 -1
  83. package/dist/cjs/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
  84. package/dist/cjs/swappers/RelaySwapper/utils/getRelayPsbtRelayer.js +7 -17
  85. package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +2 -1
  86. package/dist/cjs/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
  87. package/dist/cjs/swappers/SunioSwapper/endpoints.js +19 -36
  88. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
  89. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.js +33 -0
  90. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
  91. package/dist/cjs/swappers/SunioSwapper/utils/constants.d.ts +2 -0
  92. package/dist/cjs/swappers/SunioSwapper/utils/constants.js +7 -1
  93. package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
  94. package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +78 -0
  95. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +18 -75
  96. package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
  97. package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.js +36 -0
  98. package/dist/cjs/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
  99. package/dist/cjs/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
  100. package/dist/cjs/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
  101. package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +8 -18
  102. package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +8 -18
  103. package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
  104. package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
  105. package/dist/cjs/swappers/ThorchainSwapper/utils/longTailHelpers.js +2 -2
  106. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +2 -1
  107. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.js +7 -17
  108. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +2 -1
  109. package/dist/cjs/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
  110. package/dist/cjs/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
  111. package/dist/cjs/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
  112. package/dist/cjs/swappers/utils/helpers/helpers.js +1 -0
  113. package/dist/cjs/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
  114. package/dist/cjs/thorchain-utils/checkTradeStatus.js +8 -1
  115. package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
  116. package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.js +19 -0
  117. package/dist/cjs/thorchain-utils/cosmossdk/index.d.ts +1 -0
  118. package/dist/cjs/thorchain-utils/cosmossdk/index.js +1 -0
  119. package/dist/cjs/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
  120. package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +51 -33
  121. package/dist/cjs/thorchain-utils/getQuote.js +27 -29
  122. package/dist/cjs/thorchain-utils/index.d.ts +1 -0
  123. package/dist/cjs/thorchain-utils/index.js +19 -18
  124. package/dist/cjs/thorchain-utils/parseBuyTxHash.d.ts +1 -1
  125. package/dist/cjs/thorchain-utils/service.d.ts +3 -3
  126. package/dist/cjs/thorchain-utils/tron/getTronTransactionFees.js +8 -5
  127. package/dist/cjs/thorchain-utils/types.d.ts +1 -1
  128. package/dist/cjs/tron-utils/getTronTransactionFees.d.ts +1 -1
  129. package/dist/cjs/types.d.ts +16 -3
  130. package/dist/cjs/types.js +5 -0
  131. package/dist/cjs/utils/tenderly/storageSlots.js +20 -20
  132. package/dist/cjs/utils.d.ts +4 -4
  133. package/dist/esm/.tsbuildinfo +1 -1
  134. package/dist/esm/constants.js +9 -0
  135. package/dist/esm/index.d.ts +1 -0
  136. package/dist/esm/index.js +1 -0
  137. package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
  138. package/dist/esm/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
  139. package/dist/esm/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
  140. package/dist/esm/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
  141. package/dist/esm/swappers/AvnuSwapper/endpoints.js +2 -2
  142. package/dist/esm/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
  143. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +10 -6
  144. package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +2 -10
  145. package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +11 -15
  146. package/dist/esm/swappers/BebopSwapper/types.d.ts +65 -79
  147. package/dist/esm/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
  148. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -18
  149. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +45 -76
  150. package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
  151. package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
  152. package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.js +5 -0
  153. package/dist/esm/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
  154. package/dist/esm/swappers/BobGatewaySwapper/endpoints.js +140 -0
  155. package/dist/esm/swappers/BobGatewaySwapper/index.d.ts +3 -0
  156. package/dist/esm/swappers/BobGatewaySwapper/index.js +3 -0
  157. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
  158. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +86 -0
  159. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
  160. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +69 -0
  161. package/dist/esm/swappers/BobGatewaySwapper/types.d.ts +20 -0
  162. package/dist/esm/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
  163. package/dist/esm/swappers/BobGatewaySwapper/utils/constants.js +27 -0
  164. package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
  165. package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.js +299 -0
  166. package/dist/esm/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +2 -2
  167. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
  168. package/dist/esm/swappers/ButterSwap/test-data/routeQuote.js +4 -4
  169. package/dist/esm/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
  170. package/dist/esm/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
  171. package/dist/esm/swappers/CetusSwapper/utils/constants.d.ts +1 -1
  172. package/dist/esm/swappers/ChainflipSwapper/ChainflipSwapper.js +2 -1
  173. package/dist/esm/swappers/ChainflipSwapper/constants.d.ts +1 -1
  174. package/dist/esm/swappers/ChainflipSwapper/constants.js +4 -1
  175. package/dist/esm/swappers/ChainflipSwapper/endpoints.js +20 -0
  176. package/dist/esm/swappers/ChainflipSwapper/types.d.ts +2 -1
  177. package/dist/esm/swappers/ChainflipSwapper/types.js +1 -0
  178. package/dist/esm/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
  179. package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +26 -6
  180. package/dist/esm/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
  181. package/dist/esm/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
  182. package/dist/esm/swappers/ChainflipSwapper/utils/helpers.js +2 -1
  183. package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -1
  184. package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
  185. package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +1 -1
  186. package/dist/esm/swappers/CowSwapper/utils/cowService.d.ts +3 -3
  187. package/dist/esm/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
  188. package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
  189. package/dist/esm/swappers/NearIntentsSwapper/constants.d.ts +1 -0
  190. package/dist/esm/swappers/NearIntentsSwapper/constants.js +1 -0
  191. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -4
  192. package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
  193. package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
  194. package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +2 -2
  195. package/dist/esm/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
  196. package/dist/esm/swappers/RelaySwapper/constant.d.ts +1 -39
  197. package/dist/esm/swappers/RelaySwapper/constant.js +1 -1
  198. package/dist/esm/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
  199. package/dist/esm/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
  200. package/dist/esm/swappers/SunioSwapper/endpoints.js +19 -36
  201. package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
  202. package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.js +29 -0
  203. package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
  204. package/dist/esm/swappers/SunioSwapper/utils/constants.d.ts +2 -0
  205. package/dist/esm/swappers/SunioSwapper/utils/constants.js +6 -0
  206. package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
  207. package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +74 -0
  208. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +16 -74
  209. package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
  210. package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.js +32 -0
  211. package/dist/esm/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
  212. package/dist/esm/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
  213. package/dist/esm/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
  214. package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +1 -1
  215. package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +1 -1
  216. package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
  217. package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
  218. package/dist/esm/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
  219. package/dist/esm/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
  220. package/dist/esm/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
  221. package/dist/esm/swappers/utils/helpers/helpers.js +2 -1
  222. package/dist/esm/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
  223. package/dist/esm/thorchain-utils/checkTradeStatus.js +8 -1
  224. package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
  225. package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.js +15 -0
  226. package/dist/esm/thorchain-utils/cosmossdk/index.d.ts +1 -0
  227. package/dist/esm/thorchain-utils/cosmossdk/index.js +1 -0
  228. package/dist/esm/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
  229. package/dist/esm/thorchain-utils/getL1RateOrQuote.js +44 -16
  230. package/dist/esm/thorchain-utils/getQuote.js +27 -29
  231. package/dist/esm/thorchain-utils/index.d.ts +1 -0
  232. package/dist/esm/thorchain-utils/index.js +11 -1
  233. package/dist/esm/thorchain-utils/parseBuyTxHash.d.ts +1 -1
  234. package/dist/esm/thorchain-utils/service.d.ts +3 -3
  235. package/dist/esm/thorchain-utils/tron/getTronTransactionFees.js +8 -5
  236. package/dist/esm/thorchain-utils/types.d.ts +1 -1
  237. package/dist/esm/tron-utils/getTronTransactionFees.d.ts +1 -1
  238. package/dist/esm/types.d.ts +16 -3
  239. package/dist/esm/types.js +5 -0
  240. package/dist/esm/utils/tenderly/storageSlots.js +20 -20
  241. package/dist/esm/utils.d.ts +4 -4
  242. package/package.json +8 -7
  243. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
  244. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -57
  245. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -11
  246. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -40
  247. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -94
  248. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
  249. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -53
  250. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -11
  251. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -34
  252. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts +0 -1
  253. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -92
  254. /package/dist/{cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts → esm/swappers/BobGatewaySwapper/types.js} +0 -0
@@ -1,9 +1,11 @@
1
- import { bn } from '@shapeshiftoss/utils';
1
+ import { solAssetId } from '@shapeshiftoss/caip';
2
+ import { bn, bnOrZero } from '@shapeshiftoss/utils';
2
3
  import { Err, Ok } from '@sniptt/monads';
3
4
  import { getAddress } from 'viem';
4
5
  import { TradeQuoteError } from '../../../types.js';
5
6
  import { makeSwapErrorRight } from '../../../utils.js';
6
- import { BEBOP_DUMMY_ADDRESS, BEBOP_SOLANA_DUMMY_ADDRESS, chainIdToBebopChain } from '../types.js';
7
+ import { getTreasuryAddressFromChainId } from '../../utils/helpers/helpers.js';
8
+ import { chainIdToBebopChain } from '../types.js';
7
9
  import { bebopServiceFactory } from './bebopService.js';
8
10
  import { assetIdToBebopSolanaToken, assetIdToBebopToken } from './helpers/helpers.js';
9
11
  export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
@@ -14,14 +16,8 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
14
16
  const checksummedReceiverAddress = getAddress(receiverAddress);
15
17
  const chainName = chainIdToBebopChain[sellAsset.chainId];
16
18
  const sellAmountFormatted = bn(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
17
- // Bebop API expects slippage as percentage (not basis points like other APIs)
18
- // e.g. 0.3% → send as 0.3, not 30
19
- // See: https://api.bebop.xyz/pmm/ethereum/docs#/v3/quote_v3_quote_get
20
- const slippagePercentage = bn(slippageTolerancePercentageDecimal ?? 0.003)
21
- .times(100)
22
- .toNumber();
23
- const url = `https://api.bebop.xyz/router/${chainName}/v1/quote`;
24
- const params = new URLSearchParams({
19
+ const slippagePercentage = bn(slippageTolerancePercentageDecimal).times(100).toNumber();
20
+ const baseParams = {
25
21
  sell_tokens: sellToken,
26
22
  buy_tokens: buyToken,
27
23
  sell_amounts: sellAmountFormatted,
@@ -32,38 +28,46 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
32
28
  skip_validation: 'true',
33
29
  gasless: 'false',
34
30
  source: 'shapeshift',
35
- });
31
+ };
32
+ const jamParams = new URLSearchParams(baseParams);
33
+ const pmmParams = new URLSearchParams(baseParams);
36
34
  if (affiliateBps && affiliateBps !== '0') {
37
- params.set('fee', affiliateBps);
35
+ // JAM collects the fee on-chain and requires a recipient
36
+ jamParams.set('fee', affiliateBps);
37
+ jamParams.set('fee_recipient', getAddress(getTreasuryAddressFromChainId(buyAsset.chainId)));
38
+ // PMM attributes the fee off-chain via source
39
+ pmmParams.set('fee', affiliateBps);
38
40
  }
39
- const bebopService = bebopServiceFactory({ apiKey });
40
- const maybeResponse = await bebopService.get(`${url}?${params}`);
41
- if (maybeResponse.isErr()) {
41
+ const service = bebopServiceFactory({ apiKey });
42
+ const [maybeJam, maybePmm] = await Promise.all([
43
+ service.get(`https://api.bebop.xyz/jam/${chainName}/v2/quote`, {
44
+ params: jamParams,
45
+ }),
46
+ service.get(`https://api.bebop.xyz/pmm/${chainName}/v3/quote`, {
47
+ params: pmmParams,
48
+ }),
49
+ ]);
50
+ const maybeResponses = [maybeJam, maybePmm];
51
+ if (maybeResponses.every(maybeResponse => maybeResponse.isErr())) {
42
52
  return Err(makeSwapErrorRight({
43
53
  message: 'Failed to fetch quote from Bebop',
44
- cause: maybeResponse.unwrapErr().cause,
54
+ cause: maybeResponses[0].unwrapErr().cause,
45
55
  code: TradeQuoteError.QueryFailed,
46
56
  }));
47
57
  }
48
- const response = maybeResponse.unwrap();
49
- // Log partial route failures for debugging (these are normal and don't indicate quote failure)
50
- if (response.data.errors && Object.keys(response.data.errors).length > 0) {
51
- console.debug('[Bebop] Some routes failed (this is normal):', response.data.errors);
52
- }
53
- // Validate response has routes - only fail if there are NO valid routes
54
- if (!response.data.routes || response.data.routes.length === 0) {
58
+ const quotes = maybeResponses
59
+ .filter(maybeResponse => maybeResponse.isOk())
60
+ .map(maybeResponse => maybeResponse.unwrap().data)
61
+ .filter(quote => Boolean(quote.tx?.data));
62
+ if (!quotes.length) {
55
63
  return Err(makeSwapErrorRight({
56
- message: 'No routes available',
64
+ message: 'No route available',
57
65
  code: TradeQuoteError.NoRouteFound,
58
66
  }));
59
67
  }
60
- if (!response.data.bestPrice) {
61
- return Err(makeSwapErrorRight({
62
- message: 'No best price route specified',
63
- code: TradeQuoteError.InvalidResponse,
64
- }));
65
- }
66
- return Ok(response.data);
68
+ const getBuyAmount = (quote) => bnOrZero(Object.values(quote.buyTokens)[0]?.amount);
69
+ const bestQuote = quotes.reduce((best, quote) => getBuyAmount(quote).gt(getBuyAmount(best)) ? quote : best);
70
+ return Ok(bestQuote);
67
71
  }
68
72
  catch (error) {
69
73
  return Err(makeSwapErrorRight({
@@ -73,28 +77,20 @@ export const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncluding
73
77
  }));
74
78
  }
75
79
  };
76
- export const fetchBebopPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
77
- const address = receiveAddress || BEBOP_DUMMY_ADDRESS;
78
- return fetchBebopQuote({
79
- buyAsset,
80
- sellAsset,
81
- sellAmountIncludingProtocolFeesCryptoBaseUnit,
82
- takerAddress: address,
83
- receiverAddress: address,
84
- slippageTolerancePercentageDecimal: '0.01',
85
- affiliateBps,
86
- apiKey,
87
- });
88
- };
89
80
  export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
90
81
  try {
82
+ // Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
83
+ // always fails on-chain. Reject up front instead of returning an unexecutable quote.
84
+ if (sellAsset.assetId === solAssetId) {
85
+ return Err(makeSwapErrorRight({
86
+ message: 'Bebop Solana cannot sell native SOL',
87
+ code: TradeQuoteError.NoRouteFound,
88
+ }));
89
+ }
91
90
  const sellToken = assetIdToBebopSolanaToken(sellAsset.assetId);
92
91
  const buyToken = assetIdToBebopSolanaToken(buyAsset.assetId);
93
92
  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';
93
+ const slippagePercentage = bn(slippageTolerancePercentageDecimal).times(100).toNumber();
98
94
  const params = new URLSearchParams({
99
95
  sell_tokens: sellToken,
100
96
  buy_tokens: buyToken,
@@ -110,8 +106,7 @@ export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountInc
110
106
  if (affiliateBps && affiliateBps !== '0') {
111
107
  params.set('fee', affiliateBps);
112
108
  }
113
- const bebopService = bebopServiceFactory({ apiKey });
114
- const maybeResponse = await bebopService.get(`${url}?${params}`);
109
+ const maybeResponse = await bebopServiceFactory({ apiKey }).get('https://api.bebop.xyz/pmm/solana/v3/quote', { params });
115
110
  if (maybeResponse.isErr()) {
116
111
  const err = maybeResponse.unwrapErr();
117
112
  return Err(makeSwapErrorRight({
@@ -133,19 +128,6 @@ export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountInc
133
128
  code: TradeQuoteError.InvalidResponse,
134
129
  }));
135
130
  }
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
131
  return Ok(response.data);
150
132
  }
151
133
  catch (error) {
@@ -156,16 +138,3 @@ export const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountInc
156
138
  }));
157
139
  }
158
140
  };
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,10 +1,9 @@
1
1
  import type { AssetId, ChainId } from '@shapeshiftoss/caip';
2
2
  import type { Asset } from '@shapeshiftoss/types';
3
- import type { BebopSupportedChainId } from '../../types.js';
4
3
  export declare const isSolanaChainId: (chainId: ChainId) => boolean;
5
4
  export declare const assetIdToBebopToken: (assetId: AssetId) => string;
6
5
  export declare const assetIdToBebopSolanaToken: (assetId: AssetId) => string;
7
- export declare const isSupportedChainId: (chainId: ChainId) => chainId is BebopSupportedChainId;
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;
8
7
  export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
9
8
  buyAsset: Asset;
10
9
  sellAsset: Asset;
@@ -0,0 +1,2 @@
1
+ import type { Swapper } from '../../types.js';
2
+ export declare const bobGatewaySwapper: Swapper;
@@ -0,0 +1,5 @@
1
+ import { executeEvmTransaction } from '../../utils.js';
2
+ export const bobGatewaySwapper = {
3
+ executeEvmTransaction,
4
+ executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => signAndBroadcastTransaction(txToSign),
5
+ };
@@ -0,0 +1,2 @@
1
+ import type { SwapperApi } from '../../types.js';
2
+ export declare const bobGatewayApi: SwapperApi;
@@ -0,0 +1,140 @@
1
+ import { isGatewayError } from '@gobob/bob-sdk';
2
+ import { evm } from '@shapeshiftoss/chain-adapters';
3
+ import { TxStatus } from '@shapeshiftoss/unchained-client';
4
+ import { bnOrZero } from '@shapeshiftoss/utils';
5
+ import { getExecutableTradeStep, isExecutableTradeQuote } from '../../utils.js';
6
+ import { getBobGatewayTradeQuote } from './swapperApi/getTradeQuote.js';
7
+ import { getBobGatewayTradeRate } from './swapperApi/getTradeRate.js';
8
+ import { getBobGatewayClient, mapBobGatewayOrderStatusToTxStatus, registerBobGatewayTx, } from './utils/helpers.js';
9
+ const registeredSwapIds = new Set();
10
+ export const bobGatewayApi = {
11
+ getTradeRate: async (input, deps) => {
12
+ return (await getBobGatewayTradeRate(input, deps)).map(tradeRate => [tradeRate]);
13
+ },
14
+ getTradeQuote: async (input, deps) => {
15
+ return (await getBobGatewayTradeQuote(input, deps)).map(tradeQuote => [tradeQuote]);
16
+ },
17
+ getUnsignedUtxoTransaction: ({ stepIndex, tradeQuote, xpub, accountType, assertGetUtxoChainAdapter, }) => {
18
+ if (!isExecutableTradeQuote(tradeQuote)) {
19
+ throw new Error('[BobGateway] unable to execute a trade rate');
20
+ }
21
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
22
+ const { bobSpecific, sellAsset } = step;
23
+ const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
24
+ if (!bobSpecific?.utxoTx)
25
+ throw new Error('[BobGateway] invalid utxo transaction');
26
+ const { depositAddress, opReturnData } = bobSpecific.utxoTx;
27
+ return adapter.buildSendApiTransaction({
28
+ value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
29
+ xpub,
30
+ to: depositAddress,
31
+ accountNumber: step.accountNumber,
32
+ skipToAddressValidation: true,
33
+ chainSpecific: {
34
+ accountType,
35
+ opReturnData,
36
+ satoshiPerByte: step.feeData.chainSpecific.satsPerByte,
37
+ },
38
+ });
39
+ },
40
+ getUtxoTransactionFees: async ({ stepIndex, tradeQuote, xpub, assertGetUtxoChainAdapter }) => {
41
+ if (!isExecutableTradeQuote(tradeQuote)) {
42
+ throw new Error('[BobGateway] unable to execute a trade rate');
43
+ }
44
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
45
+ const { bobSpecific, sellAsset } = step;
46
+ const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
47
+ if (!bobSpecific?.utxoTx)
48
+ throw new Error('[BobGateway] invalid utxo transaction');
49
+ const { depositAddress, opReturnData } = bobSpecific.utxoTx;
50
+ const { fast } = await adapter.getFeeData({
51
+ to: depositAddress,
52
+ value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
53
+ chainSpecific: { pubkey: xpub, opReturnData },
54
+ sendMax: false,
55
+ });
56
+ return fast.txFee;
57
+ },
58
+ getUnsignedEvmTransaction: async ({ from, stepIndex, tradeQuote, assertGetEvmChainAdapter, supportsEIP1559, }) => {
59
+ if (!isExecutableTradeQuote(tradeQuote)) {
60
+ throw new Error('[BobGateway] unable to execute a trade rate');
61
+ }
62
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
63
+ const { accountNumber, bobSpecific, sellAsset } = step;
64
+ const adapter = assertGetEvmChainAdapter(sellAsset.chainId);
65
+ if (!bobSpecific?.evmTx)
66
+ throw new Error('[BobGateway] invalid evm transaction');
67
+ const { to, data, value } = bobSpecific.evmTx;
68
+ const feeData = await evm.getFees({ adapter, data, to, value, from, supportsEIP1559 });
69
+ // Pad the gas limit of the tx we actually broadcast to reduce the risk of out-of-gas reverts.
70
+ const gasLimit = bnOrZero(feeData.gasLimit).times(1.2).toFixed(0);
71
+ return adapter.buildCustomApiTx({
72
+ accountNumber,
73
+ from,
74
+ to,
75
+ value,
76
+ data,
77
+ ...feeData,
78
+ gasLimit,
79
+ });
80
+ },
81
+ getEvmTransactionFees: async ({ from, stepIndex, tradeQuote, supportsEIP1559, assertGetEvmChainAdapter, }) => {
82
+ if (!isExecutableTradeQuote(tradeQuote)) {
83
+ throw new Error('[BobGateway] unable to execute a trade rate');
84
+ }
85
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
86
+ const { bobSpecific, sellAsset } = step;
87
+ const adapter = assertGetEvmChainAdapter(sellAsset.chainId);
88
+ if (!bobSpecific?.evmTx)
89
+ throw new Error('[BobGateway] invalid evm transaction');
90
+ const { to, data, value } = bobSpecific.evmTx;
91
+ const feeData = await evm.getFees({ adapter, data, to, value, from, supportsEIP1559 });
92
+ return feeData.networkFeeCryptoBaseUnit;
93
+ },
94
+ checkTradeStatus: async ({ swap, config, txHash }) => {
95
+ if (!swap)
96
+ throw new Error('[BobGateway] swap is required for status check');
97
+ const orderId = swap.metadata.bobSpecific?.orderId;
98
+ if (!orderId)
99
+ throw new Error('[BobGateway] orderId is required for status check');
100
+ if (txHash && !registeredSwapIds.has(swap.id)) {
101
+ try {
102
+ await registerBobGatewayTx({
103
+ config,
104
+ orderId,
105
+ txHash,
106
+ sellAsset: swap.sellAsset,
107
+ buyAsset: swap.buyAsset,
108
+ });
109
+ registeredSwapIds.add(swap.id);
110
+ }
111
+ catch { }
112
+ }
113
+ let orderInfo;
114
+ try {
115
+ orderInfo = await getBobGatewayClient(config).getOrder(orderId);
116
+ }
117
+ catch (err) {
118
+ if (isGatewayError(err)) {
119
+ if (err.code === 'ORDER_NOT_FOUND') {
120
+ return {
121
+ buyTxHash: undefined,
122
+ status: TxStatus.Unknown,
123
+ message: 'Waiting for deposit...',
124
+ };
125
+ }
126
+ }
127
+ throw err;
128
+ }
129
+ const status = mapBobGatewayOrderStatusToTxStatus(orderInfo.status);
130
+ const buyTxHash = 'success' in orderInfo.status ? orderInfo.status.success.receivedTokens[0]?.txHash : undefined;
131
+ const refundTxHash = 'refunded' in orderInfo.status
132
+ ? orderInfo.status.refunded.refundedTokens[0]?.txHash
133
+ : undefined;
134
+ return {
135
+ status,
136
+ buyTxHash,
137
+ message: refundTxHash ? 'Trade refunded' : undefined,
138
+ };
139
+ },
140
+ };
@@ -0,0 +1,3 @@
1
+ export { bobGatewayApi } from './endpoints.js';
2
+ export { bobGatewaySwapper } from './BobGatewaySwapper.js';
3
+ export * from './utils/constants.js';
@@ -0,0 +1,3 @@
1
+ export { bobGatewayApi } from './endpoints.js';
2
+ export { bobGatewaySwapper } from './BobGatewaySwapper.js';
3
+ export * from './utils/constants.js';
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { CommonTradeQuoteInput, SwapErrorRight, SwapperDeps, TradeQuote } from '../../../types.js';
3
+ export declare const getBobGatewayTradeQuote: (input: CommonTradeQuoteInput, deps: SwapperDeps) => Promise<Result<TradeQuote, SwapErrorRight>>;
@@ -0,0 +1,86 @@
1
+ import { isEvmChainId } from '@shapeshiftoss/chain-adapters';
2
+ import { Err, Ok } from '@sniptt/monads';
3
+ import { v4 as uuid } from 'uuid';
4
+ import { SwapperName, TradeQuoteError } from '../../../types.js';
5
+ import { getInputOutputRate, makeSwapErrorRight } from '../../../utils.js';
6
+ import { assertValidTrade, createBobGatewayOrderMetadata, getBobGatewayAllowanceContract, getBobGatewayQuote, getBobGatewayQuoteFeeData, parseBobGatewayQuote, } from '../utils/helpers.js';
7
+ export const getBobGatewayTradeQuote = async (input, deps) => {
8
+ const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, sendAddress, receiveAddress, accountNumber, affiliateBps, slippageTolerancePercentageDecimal, } = input;
9
+ const { config } = deps;
10
+ if (!sendAddress) {
11
+ return Err(makeSwapErrorRight({
12
+ message: '[BobGateway] sendAddress is required for quote',
13
+ code: TradeQuoteError.UnknownError,
14
+ }));
15
+ }
16
+ if (!receiveAddress) {
17
+ return Err(makeSwapErrorRight({
18
+ message: '[BobGateway] receiveAddress is required for quote',
19
+ code: TradeQuoteError.UnknownError,
20
+ }));
21
+ }
22
+ const assertion = assertValidTrade({ sellAsset, buyAsset });
23
+ if (assertion.isErr())
24
+ return Err(assertion.unwrapErr());
25
+ const { sellChainName, buyChainName } = assertion.unwrap();
26
+ // omit the sender for utxo sells so order creation does not enforce a per-address confirmed
27
+ // funds check (deposits are matched via op_return, not the sending address)
28
+ const sender = isEvmChainId(sellAsset.chainId) ? sendAddress : undefined;
29
+ const maybeQuote = await getBobGatewayQuote({
30
+ config,
31
+ sellAsset,
32
+ buyAsset,
33
+ sellChainName,
34
+ buyChainName,
35
+ sender,
36
+ recipient: receiveAddress,
37
+ amount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
38
+ affiliateBps,
39
+ slippageTolerancePercentageDecimal,
40
+ });
41
+ if (maybeQuote.isErr())
42
+ return Err(maybeQuote.unwrapErr());
43
+ const quote = maybeQuote.unwrap();
44
+ const maybeOrderMetadata = await createBobGatewayOrderMetadata(config, quote);
45
+ if (maybeOrderMetadata.isErr())
46
+ return Err(maybeOrderMetadata.unwrapErr());
47
+ const orderMetadata = maybeOrderMetadata.unwrap();
48
+ const maybeFeeData = await getBobGatewayQuoteFeeData(input, deps, orderMetadata);
49
+ if (maybeFeeData.isErr())
50
+ return Err(maybeFeeData.unwrapErr());
51
+ const feeData = maybeFeeData.unwrap();
52
+ const { buyAmountBeforeFeesCryptoBaseUnit, buyAmountAfterFeesCryptoBaseUnit, protocolFees, estimatedExecutionTimeMs, } = parseBobGatewayQuote(quote, buyAsset, deps.assetsById);
53
+ const rate = getInputOutputRate({
54
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
55
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
56
+ sellAsset,
57
+ buyAsset,
58
+ });
59
+ const allowanceContract = getBobGatewayAllowanceContract(quote, sellAsset);
60
+ const tradeQuote = {
61
+ id: uuid(),
62
+ quoteOrRate: 'quote',
63
+ rate,
64
+ receiveAddress,
65
+ affiliateBps,
66
+ slippageTolerancePercentageDecimal,
67
+ swapperName: SwapperName.BobGateway,
68
+ steps: [
69
+ {
70
+ buyAmountBeforeFeesCryptoBaseUnit,
71
+ buyAmountAfterFeesCryptoBaseUnit,
72
+ sellAmountIncludingProtocolFeesCryptoBaseUnit,
73
+ feeData: { ...feeData, protocolFees },
74
+ rate,
75
+ source: SwapperName.BobGateway,
76
+ buyAsset,
77
+ sellAsset,
78
+ accountNumber,
79
+ allowanceContract,
80
+ estimatedExecutionTimeMs,
81
+ bobSpecific: orderMetadata,
82
+ },
83
+ ],
84
+ };
85
+ return Ok(tradeQuote);
86
+ };
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { GetTradeRateInput, SwapErrorRight, SwapperDeps, TradeRate } from '../../../types.js';
3
+ export declare const getBobGatewayTradeRate: (input: GetTradeRateInput, deps: SwapperDeps) => Promise<Result<TradeRate, SwapErrorRight>>;
@@ -0,0 +1,69 @@
1
+ import { btcChainId } from '@shapeshiftoss/caip';
2
+ import { Err, Ok } from '@sniptt/monads';
3
+ import { v4 as uuid } from 'uuid';
4
+ import { SwapperName } from '../../../types.js';
5
+ import { getInputOutputRate } from '../../../utils.js';
6
+ import { DUMMY_BTC_ADDRESS, DUMMY_EVM_ADDRESS } from '../utils/constants.js';
7
+ import { assertValidTrade, getBobGatewayAllowanceContract, getBobGatewayQuote, getBobGatewayRateNetworkFeeCryptoBaseUnit, parseBobGatewayQuote, } from '../utils/helpers.js';
8
+ export const getBobGatewayTradeRate = async (input, deps) => {
9
+ const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, accountNumber, affiliateBps, slippageTolerancePercentageDecimal, } = input;
10
+ const { config } = deps;
11
+ const assertion = assertValidTrade({ sellAsset, buyAsset });
12
+ if (assertion.isErr())
13
+ return Err(assertion.unwrapErr());
14
+ const { sellChainName, buyChainName } = assertion.unwrap();
15
+ const recipient = receiveAddress ?? (buyAsset.chainId === btcChainId ? DUMMY_BTC_ADDRESS : DUMMY_EVM_ADDRESS);
16
+ const sender = sellAsset.chainId === btcChainId ? undefined : DUMMY_EVM_ADDRESS;
17
+ const maybeQuote = await getBobGatewayQuote({
18
+ config,
19
+ sellAsset,
20
+ buyAsset,
21
+ sellChainName,
22
+ buyChainName,
23
+ sender,
24
+ recipient,
25
+ amount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
26
+ affiliateBps,
27
+ slippageTolerancePercentageDecimal,
28
+ });
29
+ if (maybeQuote.isErr())
30
+ return Err(maybeQuote.unwrapErr());
31
+ const quote = maybeQuote.unwrap();
32
+ const { buyAmountBeforeFeesCryptoBaseUnit, buyAmountAfterFeesCryptoBaseUnit, protocolFees, estimatedExecutionTimeMs, } = parseBobGatewayQuote(quote, buyAsset, deps.assetsById);
33
+ const rate = getInputOutputRate({
34
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
35
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
36
+ sellAsset,
37
+ buyAsset,
38
+ });
39
+ const allowanceContract = getBobGatewayAllowanceContract(quote, sellAsset);
40
+ const networkFeeCryptoBaseUnit = await getBobGatewayRateNetworkFeeCryptoBaseUnit(quote, sellAsset, deps);
41
+ const tradeRate = {
42
+ id: uuid(),
43
+ quoteOrRate: 'rate',
44
+ rate,
45
+ receiveAddress,
46
+ affiliateBps,
47
+ slippageTolerancePercentageDecimal,
48
+ swapperName: SwapperName.BobGateway,
49
+ steps: [
50
+ {
51
+ buyAmountBeforeFeesCryptoBaseUnit,
52
+ buyAmountAfterFeesCryptoBaseUnit,
53
+ sellAmountIncludingProtocolFeesCryptoBaseUnit,
54
+ feeData: {
55
+ networkFeeCryptoBaseUnit,
56
+ protocolFees,
57
+ },
58
+ rate,
59
+ source: SwapperName.BobGateway,
60
+ buyAsset,
61
+ sellAsset,
62
+ accountNumber,
63
+ allowanceContract,
64
+ estimatedExecutionTimeMs,
65
+ },
66
+ ],
67
+ };
68
+ return Ok(tradeRate);
69
+ };
@@ -0,0 +1,20 @@
1
+ type BobGatewayEvmTxMetadata = {
2
+ to: string;
3
+ data: string;
4
+ value: string;
5
+ chain: string;
6
+ };
7
+ type BobGatewayUtxoTxMetadata = {
8
+ depositAddress: string;
9
+ opReturnData?: string;
10
+ };
11
+ export type BobGatewayMetadata = {
12
+ orderId: string;
13
+ } & ({
14
+ evmTx: BobGatewayEvmTxMetadata;
15
+ utxoTx?: never;
16
+ } | {
17
+ utxoTx: BobGatewayUtxoTxMetadata;
18
+ evmTx?: never;
19
+ });
20
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { ChainId } from '@shapeshiftoss/caip';
2
+ export declare const BOB_GATEWAY_BASE_URL = "https://gateway-api-mainnet.gobob.xyz";
3
+ export declare const chainIdToBobGatewayChainName: {
4
+ readonly [x: string]: "arbitrum" | "avalanche" | "base" | "bera" | "bitcoin" | "bob" | "bsc" | "ethereum" | "sei" | "sonic" | "unichain";
5
+ };
6
+ export declare const bobGatewayChainNameToChainId: Record<BobGatewayChainName, ChainId>;
7
+ export type BobGatewayChainName = (typeof chainIdToBobGatewayChainName)[keyof typeof chainIdToBobGatewayChainName];
8
+ export declare const DUMMY_EVM_ADDRESS: `0x${string}`;
9
+ export declare const DUMMY_BTC_ADDRESS = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq";
10
+ export declare const BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = "350000";
11
+ export declare const BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = "550000";
12
+ export declare const BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE = "200";
13
+ export declare const decimalSlippageToBobBps: (slippageDecimal: string) => string;
@@ -0,0 +1,27 @@
1
+ import { arbitrumChainId, avalancheChainId, baseChainId, berachainChainId, bobChainId, bscChainId, btcChainId, ethChainId, seiChainId, sonicChainId, unichainChainId, } from '@shapeshiftoss/caip';
2
+ export const BOB_GATEWAY_BASE_URL = 'https://gateway-api-mainnet.gobob.xyz';
3
+ // Chain name strings expected by the BOB Gateway API
4
+ // https://gateway-api-mainnet.gobob.xyz/v2/get-routes
5
+ export const chainIdToBobGatewayChainName = {
6
+ [arbitrumChainId]: 'arbitrum',
7
+ [avalancheChainId]: 'avalanche',
8
+ [baseChainId]: 'base',
9
+ [berachainChainId]: 'bera',
10
+ [btcChainId]: 'bitcoin',
11
+ [bobChainId]: 'bob',
12
+ [bscChainId]: 'bsc',
13
+ [ethChainId]: 'ethereum',
14
+ [seiChainId]: 'sei',
15
+ [sonicChainId]: 'sonic',
16
+ [unichainChainId]: 'unichain',
17
+ };
18
+ export const bobGatewayChainNameToChainId = Object.fromEntries(Object.entries(chainIdToBobGatewayChainName).map(([chainId, chainName]) => [chainName, chainId]));
19
+ export const DUMMY_EVM_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
20
+ export const DUMMY_BTC_ADDRESS = 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq';
21
+ export const BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = '350000'; // EVM→EVM
22
+ export const BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = '550000'; // EVM→BTC
23
+ export const BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE = '200'; // BTC→EVM
24
+ // https://docs.gobob.xyz/api-reference/v2/get-a-gateway-quote#parameter-slippage
25
+ export const decimalSlippageToBobBps = (slippageDecimal) => {
26
+ return String(Math.round(parseFloat(slippageDecimal) * 10_000));
27
+ };
@@ -0,0 +1,49 @@
1
+ import type { GatewayOrderStatusV2, GatewayQuoteV2, GetQuoteParams } from '@gobob/bob-sdk';
2
+ import { GatewaySDK } from '@gobob/bob-sdk';
3
+ import type { AssetId } from '@shapeshiftoss/caip';
4
+ import type { Asset, AssetsByIdPartial } from '@shapeshiftoss/types';
5
+ import { TxStatus } from '@shapeshiftoss/unchained-client';
6
+ import type { Result } from '@sniptt/monads';
7
+ import type { GetTradeQuoteInput, QuoteFeeData, SwapErrorRight, SwapperConfig, SwapperDeps } from '../../../types.js';
8
+ import type { BobGatewayMetadata } from '../types.js';
9
+ import type { BobGatewayChainName } from './constants.js';
10
+ export declare const getBobGatewayClient: (config: SwapperConfig) => GatewaySDK;
11
+ export declare const assetIdToBobGatewayToken: (assetId: string) => string;
12
+ export declare const getBobGatewayAffiliates: (affiliateBps: string) => GetQuoteParams['affiliates'];
13
+ export declare const getBobGatewayQuote: ({ config, sellAsset, buyAsset, sellChainName, buyChainName, sender, recipient, amount, affiliateBps, slippageTolerancePercentageDecimal, }: {
14
+ config: SwapperConfig;
15
+ sellAsset: Asset;
16
+ buyAsset: Asset;
17
+ sellChainName: BobGatewayChainName;
18
+ buyChainName: BobGatewayChainName;
19
+ sender: string | undefined;
20
+ recipient: string;
21
+ amount: string;
22
+ affiliateBps: string;
23
+ slippageTolerancePercentageDecimal: string | undefined;
24
+ }) => Promise<Result<GatewayQuoteV2, SwapErrorRight>>;
25
+ export declare const createBobGatewayOrderMetadata: (config: SwapperConfig, gatewayQuote: GatewayQuoteV2) => Promise<Result<BobGatewayMetadata, SwapErrorRight>>;
26
+ export declare const registerBobGatewayTx: ({ config, orderId, txHash, sellAsset, buyAsset, }: {
27
+ config: SwapperConfig;
28
+ orderId: string;
29
+ txHash: string;
30
+ sellAsset: Asset;
31
+ buyAsset: Asset;
32
+ }) => Promise<void>;
33
+ export declare const getBobGatewayQuoteFeeData: (input: GetTradeQuoteInput, { assertGetUtxoChainAdapter, assertGetEvmChainAdapter }: SwapperDeps, orderMetadata: BobGatewayMetadata) => Promise<Result<Omit<QuoteFeeData, 'protocolFees'>, SwapErrorRight>>;
34
+ export declare const getBobGatewayRateNetworkFeeCryptoBaseUnit: (quote: GatewayQuoteV2, sellAsset: Asset, { assertGetEvmChainAdapter, assertGetUtxoChainAdapter }: SwapperDeps) => Promise<string | undefined>;
35
+ export declare const mapBobGatewayOrderStatusToTxStatus: (status: GatewayOrderStatusV2) => TxStatus;
36
+ export declare const parseBobGatewayQuote: (quote: GatewayQuoteV2, buyAsset: Asset, assetsById: AssetsByIdPartial) => {
37
+ buyAmountBeforeFeesCryptoBaseUnit: string;
38
+ buyAmountAfterFeesCryptoBaseUnit: string;
39
+ protocolFees: Partial<Record<AssetId, import("../../../types.js").ProtocolFee>>;
40
+ estimatedExecutionTimeMs: number | undefined;
41
+ };
42
+ export declare const getBobGatewayAllowanceContract: (quote: GatewayQuoteV2, sellAsset: Asset) => string;
43
+ export declare const assertValidTrade: ({ sellAsset, buyAsset, }: {
44
+ sellAsset: Asset;
45
+ buyAsset: Asset;
46
+ }) => Result<{
47
+ sellChainName: BobGatewayChainName;
48
+ buyChainName: BobGatewayChainName;
49
+ }, SwapErrorRight>;