@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
@@ -0,0 +1,299 @@
1
+ import { GatewayErrorCode, GatewaySDK, isGatewayError } from '@gobob/bob-sdk';
2
+ import { ASSET_NAMESPACE, ethChainId, fromAssetId, toAssetId } from '@shapeshiftoss/caip';
3
+ import { evm, isEvmChainId } from '@shapeshiftoss/chain-adapters';
4
+ import { TxStatus } from '@shapeshiftoss/unchained-client';
5
+ import { bnOrZero, chainIdToFeeAssetId, contractAddressOrUndefined, isToken, } from '@shapeshiftoss/utils';
6
+ import { Err, Ok } from '@sniptt/monads';
7
+ import { getAddress, zeroAddress } from 'viem';
8
+ import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
9
+ import { SwapperName, TradeQuoteError } from '../../../types.js';
10
+ import { createTradeAmountTooSmallErr, makeSwapErrorRight } from '../../../utils.js';
11
+ import { getTreasuryAddressFromChainId } from '../../utils/helpers/helpers.js';
12
+ import { BOB_GATEWAY_BASE_URL, BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT, BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE, BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT, bobGatewayChainNameToChainId, chainIdToBobGatewayChainName, decimalSlippageToBobBps, } from './constants.js';
13
+ export const getBobGatewayClient = (config) => {
14
+ return new GatewaySDK({ basePath: BOB_GATEWAY_BASE_URL, apiKey: config.VITE_BOB_GATEWAY_API_KEY });
15
+ };
16
+ export const assetIdToBobGatewayToken = (assetId) => {
17
+ // BOB Gateway uses the zero address as the token address for native assets
18
+ if (!isToken(assetId))
19
+ return zeroAddress;
20
+ return fromAssetId(assetId).assetReference;
21
+ };
22
+ export const getBobGatewayAffiliates = (affiliateBps) => {
23
+ const bps = bnOrZero(affiliateBps);
24
+ if (!bps.isFinite() || bps.lte(0))
25
+ return undefined;
26
+ const affiliateAddress = getTreasuryAddressFromChainId(ethChainId);
27
+ return [{ address: getAddress(affiliateAddress), bps: bps.toNumber() }];
28
+ };
29
+ export const getBobGatewayQuote = async ({ config, sellAsset, buyAsset, sellChainName, buyChainName, sender, recipient, amount, affiliateBps, slippageTolerancePercentageDecimal, }) => {
30
+ const slippage = decimalSlippageToBobBps(slippageTolerancePercentageDecimal ??
31
+ getDefaultSlippageDecimalPercentageForSwapper(SwapperName.BobGateway));
32
+ try {
33
+ const quote = await getBobGatewayClient(config).getQuote({
34
+ fromChain: sellChainName,
35
+ toChain: buyChainName,
36
+ fromToken: assetIdToBobGatewayToken(sellAsset.assetId),
37
+ toToken: assetIdToBobGatewayToken(buyAsset.assetId),
38
+ fromUserAddress: sender,
39
+ toUserAddress: recipient,
40
+ amount,
41
+ maxSlippage: Number(slippage),
42
+ affiliates: getBobGatewayAffiliates(affiliateBps),
43
+ });
44
+ return Ok(quote);
45
+ }
46
+ catch (err) {
47
+ if (isGatewayError(err)) {
48
+ switch (err.code) {
49
+ case GatewayErrorCode.QuoteAmountTooLow:
50
+ return Err(createTradeAmountTooSmallErr({
51
+ minAmountCryptoBaseUnit: err.details.minimum,
52
+ assetId: sellAsset.assetId,
53
+ }));
54
+ case GatewayErrorCode.UnableToCoverFees:
55
+ return Err(makeSwapErrorRight({
56
+ message: '[BobGateway] sell amount does not cover fees',
57
+ code: TradeQuoteError.SellAmountBelowTradeFee,
58
+ cause: err,
59
+ }));
60
+ case GatewayErrorCode.NoRoute:
61
+ return Err(makeSwapErrorRight({
62
+ message: '[BobGateway] no route found for trade pair',
63
+ code: TradeQuoteError.NoRouteFound,
64
+ cause: err,
65
+ }));
66
+ case GatewayErrorCode.DisabledChain:
67
+ return Err(makeSwapErrorRight({
68
+ message: '[BobGateway] trading is temporarily halted for this chain',
69
+ code: TradeQuoteError.TradingHalted,
70
+ cause: err,
71
+ }));
72
+ default:
73
+ break;
74
+ }
75
+ }
76
+ return Err(makeSwapErrorRight({
77
+ message: '[BobGateway] failed to fetch quote',
78
+ code: TradeQuoteError.QueryFailed,
79
+ cause: err,
80
+ }));
81
+ }
82
+ };
83
+ export const createBobGatewayOrderMetadata = async (config, gatewayQuote) => {
84
+ try {
85
+ const orderResponse = await getBobGatewayClient(config).api.createOrderV2({
86
+ gatewayQuoteV2: gatewayQuote,
87
+ });
88
+ // onramp (BTC→EVM)
89
+ if ('onramp' in orderResponse) {
90
+ return Ok({
91
+ orderId: orderResponse.onramp.orderId,
92
+ utxoTx: {
93
+ depositAddress: orderResponse.onramp.address,
94
+ opReturnData: orderResponse.onramp.opReturnData ?? undefined,
95
+ },
96
+ });
97
+ }
98
+ // offramp (EVM→BTC) and tokenSwap (EVM→EVM) orders share the same tx shape
99
+ const order = 'offramp' in orderResponse ? orderResponse.offramp : orderResponse.tokenSwap;
100
+ return Ok({
101
+ orderId: order.orderId,
102
+ evmTx: {
103
+ to: order.tx.to,
104
+ data: order.tx.data,
105
+ value: order.tx.value,
106
+ chain: order.tx.chain,
107
+ },
108
+ });
109
+ }
110
+ catch (err) {
111
+ if (isGatewayError(err) && err.code === GatewayErrorCode.InsufficientConfirmedFunds) {
112
+ return Err(makeSwapErrorRight({
113
+ message: '[BobGateway] insufficient confirmed balance',
114
+ code: TradeQuoteError.InsufficientFundsUnconfirmed,
115
+ cause: err,
116
+ }));
117
+ }
118
+ return Err(makeSwapErrorRight({
119
+ message: '[BobGateway] failed to create order',
120
+ code: TradeQuoteError.QueryFailed,
121
+ cause: err,
122
+ }));
123
+ }
124
+ };
125
+ export const registerBobGatewayTx = async ({ config, orderId, txHash, sellAsset, buyAsset, }) => {
126
+ const registerTxV2 = (() => {
127
+ // BTC→EVM
128
+ if (chainIdToBobGatewayChainName[sellAsset.chainId] === 'bitcoin') {
129
+ return { onramp: { orderId, bitcoinTxid: txHash } };
130
+ }
131
+ // EVM→BTC
132
+ if (chainIdToBobGatewayChainName[buyAsset.chainId] === 'bitcoin') {
133
+ return { offramp: { orderId, evmTxhash: txHash } };
134
+ }
135
+ // EVM→EVM
136
+ return { tokenSwap: { orderId, evmTxhash: txHash } };
137
+ })();
138
+ await getBobGatewayClient(config).api.registerTxV2({ registerTxV2 });
139
+ };
140
+ export const getBobGatewayQuoteFeeData = async (input, { assertGetUtxoChainAdapter, assertGetEvmChainAdapter }, orderMetadata) => {
141
+ const { sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
142
+ try {
143
+ if (orderMetadata.utxoTx && 'xpub' in input) {
144
+ const { depositAddress, opReturnData } = orderMetadata.utxoTx;
145
+ const { fast } = await assertGetUtxoChainAdapter(sellAsset.chainId).getFeeData({
146
+ to: depositAddress,
147
+ value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
148
+ chainSpecific: { pubkey: input.xpub, opReturnData },
149
+ sendMax: false,
150
+ });
151
+ return Ok({
152
+ networkFeeCryptoBaseUnit: fast.txFee,
153
+ chainSpecific: { satsPerByte: fast.chainSpecific.satoshiPerByte },
154
+ });
155
+ }
156
+ if (orderMetadata.evmTx && input.sendAddress && 'supportsEIP1559' in input) {
157
+ const { to, data, value } = orderMetadata.evmTx;
158
+ const { networkFeeCryptoBaseUnit } = await evm.getFees({
159
+ adapter: assertGetEvmChainAdapter(sellAsset.chainId),
160
+ to,
161
+ data,
162
+ value,
163
+ from: input.sendAddress,
164
+ supportsEIP1559: input.supportsEIP1559,
165
+ });
166
+ return Ok({ networkFeeCryptoBaseUnit });
167
+ }
168
+ throw new Error('[BobGateway] invalid quote');
169
+ }
170
+ catch (err) {
171
+ return Err(makeSwapErrorRight({
172
+ message: '[BobGateway] failed to estimate network fee',
173
+ code: TradeQuoteError.NetworkFeeEstimationFailed,
174
+ cause: err,
175
+ }));
176
+ }
177
+ };
178
+ export const getBobGatewayRateNetworkFeeCryptoBaseUnit = async (quote, sellAsset, { assertGetEvmChainAdapter, assertGetUtxoChainAdapter }) => {
179
+ try {
180
+ if ('onramp' in quote) {
181
+ const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
182
+ const { fast } = await adapter.httpProvider.getNetworkFees();
183
+ if (!fast?.satsPerKiloByte)
184
+ return undefined;
185
+ const satsPerByte = Math.max(1, Math.ceil(fast.satsPerKiloByte / 1000));
186
+ return bnOrZero(satsPerByte).times(BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE).toFixed(0);
187
+ }
188
+ const defaultGasLimit = 'offramp' in quote
189
+ ? BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT
190
+ : BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT;
191
+ const { average } = await assertGetEvmChainAdapter(sellAsset.chainId).getGasFeeData();
192
+ const feePerGas = bnOrZero(average.maxFeePerGas).gt(0) ? average.maxFeePerGas : average.gasPrice;
193
+ return bnOrZero(defaultGasLimit).times(bnOrZero(feePerGas)).toFixed(0);
194
+ }
195
+ catch {
196
+ return undefined;
197
+ }
198
+ };
199
+ export const mapBobGatewayOrderStatusToTxStatus = (status) => {
200
+ if ('inProgress' in status)
201
+ return TxStatus.Pending;
202
+ if ('success' in status)
203
+ return TxStatus.Confirmed;
204
+ if ('failed' in status)
205
+ return TxStatus.Failed;
206
+ if ('refunded' in status)
207
+ return TxStatus.Failed;
208
+ return TxStatus.Unknown;
209
+ };
210
+ const bobGatewayFeeToAssetId = (fee) => {
211
+ const chainId = bobGatewayChainNameToChainId[fee.chain];
212
+ if (!chainId)
213
+ return;
214
+ if (fee.address.toLowerCase() === zeroAddress)
215
+ return chainIdToFeeAssetId(chainId);
216
+ return toAssetId({
217
+ chainId,
218
+ assetNamespace: ASSET_NAMESPACE.erc20,
219
+ assetReference: fee.address,
220
+ });
221
+ };
222
+ export const parseBobGatewayQuote = (quote, buyAsset, assetsById) => {
223
+ const { outputAmount, estimatedTimeInSecs, fees } = (() => {
224
+ if ('onramp' in quote) {
225
+ const { outputAmount, estimatedTimeInSecs, fees } = quote.onramp;
226
+ return { outputAmount, estimatedTimeInSecs, fees: [fees] };
227
+ }
228
+ if ('offramp' in quote) {
229
+ const { outputAmount, estimatedTimeInSecs, feeBreakdown } = quote.offramp;
230
+ const { affiliateFee, inclusionFee, protocolFee, solverFee } = feeBreakdown;
231
+ return {
232
+ outputAmount,
233
+ estimatedTimeInSecs,
234
+ fees: [affiliateFee, inclusionFee, protocolFee, solverFee],
235
+ };
236
+ }
237
+ const { outputAmount, estimatedTimeInSecs, fees } = quote.tokenSwap;
238
+ return { outputAmount, estimatedTimeInSecs, fees: [fees] };
239
+ })();
240
+ const protocolFees = fees.reduce((acc, fee) => {
241
+ const amountCryptoBaseUnit = bnOrZero(fee.amount);
242
+ if (amountCryptoBaseUnit.lte(0))
243
+ return acc;
244
+ const assetId = bobGatewayFeeToAssetId(fee);
245
+ if (!assetId)
246
+ return acc;
247
+ const asset = assetId === buyAsset.assetId ? buyAsset : assetsById[assetId];
248
+ if (!asset)
249
+ return acc;
250
+ acc[assetId] = {
251
+ amountCryptoBaseUnit: bnOrZero(acc[assetId]?.amountCryptoBaseUnit)
252
+ .plus(amountCryptoBaseUnit)
253
+ .toFixed(),
254
+ asset,
255
+ requiresBalance: false,
256
+ };
257
+ return acc;
258
+ }, {});
259
+ // buyAmountBeforeFees is denominated in the buy asset, so only add back buy-asset-denominated fees
260
+ const buyAssetFeeCryptoBaseUnit = bnOrZero(protocolFees[buyAsset.assetId]?.amountCryptoBaseUnit);
261
+ return {
262
+ buyAmountBeforeFeesCryptoBaseUnit: buyAssetFeeCryptoBaseUnit
263
+ .plus(bnOrZero(outputAmount.amount))
264
+ .toFixed(),
265
+ buyAmountAfterFeesCryptoBaseUnit: outputAmount.amount,
266
+ protocolFees,
267
+ estimatedExecutionTimeMs: typeof estimatedTimeInSecs === 'number' ? estimatedTimeInSecs * 1000 : undefined,
268
+ };
269
+ };
270
+ export const getBobGatewayAllowanceContract = (quote, sellAsset) => {
271
+ if (!isEvmChainId(sellAsset.chainId))
272
+ return '';
273
+ if (!contractAddressOrUndefined(sellAsset.assetId))
274
+ return '';
275
+ if ('offramp' in quote)
276
+ return quote.offramp.txTo;
277
+ if ('tokenSwap' in quote)
278
+ return quote.tokenSwap.txTo;
279
+ return '';
280
+ };
281
+ export const assertValidTrade = ({ sellAsset, buyAsset, }) => {
282
+ const sellChainName = chainIdToBobGatewayChainName[sellAsset.chainId];
283
+ const buyChainName = chainIdToBobGatewayChainName[buyAsset.chainId];
284
+ if (!sellChainName) {
285
+ return Err(makeSwapErrorRight({
286
+ message: `[BobGateway] unsupported sell chain: ${sellAsset.chainId}`,
287
+ code: TradeQuoteError.UnsupportedChain,
288
+ details: { chainId: sellAsset.chainId },
289
+ }));
290
+ }
291
+ if (!buyChainName) {
292
+ return Err(makeSwapErrorRight({
293
+ message: `[BobGateway] unsupported buy chain: ${buyAsset.chainId}`,
294
+ code: TradeQuoteError.UnsupportedChain,
295
+ details: { chainId: buyAsset.chainId },
296
+ }));
297
+ }
298
+ return Ok({ sellChainName, buyChainName });
299
+ };
@@ -120,7 +120,7 @@ describe('checkTradeStatus same-chain short-circuit', () => {
120
120
  it('should proceed to bridge polling for cross-chain swaps', async () => {
121
121
  const mockBridgeInfo = {
122
122
  id: 12345,
123
- state: 1, // Confirmed
123
+ state: 1,
124
124
  toHash: 'dest-tx',
125
125
  relayerHash: 'relayer-tx',
126
126
  relayerChain: { scanUrl: 'https://scan.url' },
@@ -164,7 +164,7 @@ describe('checkTradeStatus same-chain short-circuit', () => {
164
164
  txHash: mockTxHash,
165
165
  chainId: mockEvmChainId,
166
166
  address: mockAddress,
167
- swap: undefined, // No swap data
167
+ swap: undefined,
168
168
  assertGetEvmChainAdapter: mockAssertGetEvmChainAdapter,
169
169
  assertGetSolanaChainAdapter: mockAssertGetSolanaChainAdapter,
170
170
  fetchIsSmartContractAddressQuery: mockFetchIsSmartContractAddressQuery,
@@ -71,7 +71,7 @@ export const getTradeQuote = async (input, _deps) => {
71
71
  const buildTxResult = await fetchTxData({
72
72
  hash: route.hash,
73
73
  slippage,
74
- from: sendAddress, // from (source chain address)
74
+ from: sendAddress,
75
75
  receiver: receiveAddress, // receiver (destination chain address)
76
76
  });
77
77
  if (buildTxResult.isErr())
@@ -14,12 +14,12 @@ export const ROUTE_QUOTE = {
14
14
  },
15
15
  tradeType: 0,
16
16
  gasFee: {
17
- amount: '0.001333043669759539', // human units
17
+ amount: '0.001333043669759539',
18
18
  symbol: 'ETH',
19
19
  inUSD: '3.0629382849310107',
20
20
  },
21
21
  swapFee: {
22
- nativeFee: '0.0', // human units
22
+ nativeFee: '0.0',
23
23
  tokenFee: '0.001', // human units
24
24
  },
25
25
  feeConfig: {
@@ -50,8 +50,8 @@ export const ROUTE_QUOTE = {
50
50
  symbol: 'USDC',
51
51
  icon: 'https://s3.amazonaws.com/map-static-file/mapSwap/ethereum/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/logo.png',
52
52
  },
53
- totalAmountIn: '0.999', // in human units
54
- totalAmountOut: '2296.409699', // in human units
53
+ totalAmountIn: '0.999',
54
+ totalAmountOut: '2296.409699',
55
55
  route: [
56
56
  {
57
57
  amountIn: '0.999',
@@ -1,6 +1,6 @@
1
1
  import type { AxiosRequestConfig } from 'axios';
2
2
  export declare const butterHistoryService: {
3
- get: <T = any>(url: string, config?: AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
4
- post: <T = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
5
- delete: <T = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
3
+ get: <T = any>(url: string, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../../index.js").SwapErrorRight>>;
4
+ post: <T_1 = any>(url: string, data: any, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../../../index.js").SwapErrorRight>>;
5
+ delete: <T_2 = any>(url: string, data: any, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../../../index.js").SwapErrorRight>>;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import type { AxiosRequestConfig } from 'axios';
2
2
  export declare const butterService: {
3
- get: <T = any>(url: string, config?: AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
4
- post: <T = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
5
- delete: <T = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
3
+ get: <T = any>(url: string, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../../index.js").SwapErrorRight>>;
4
+ post: <T_1 = any>(url: string, data: any, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../../../index.js").SwapErrorRight>>;
5
+ delete: <T_2 = any>(url: string, data: any, config?: AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../../../index.js").SwapErrorRight>>;
6
6
  };
@@ -1,4 +1,4 @@
1
1
  import type { ChainId } from '@shapeshiftoss/caip';
2
2
  export declare const SUPPORTED_CETUS_CHAIN_IDS: readonly ChainId[];
3
- export declare const isSupportedChainId: (chainId: ChainId) => chainId is (typeof SUPPORTED_CETUS_CHAIN_IDS)[number];
3
+ export declare const isSupportedChainId: (chainId: ChainId) => chainId is ChainId;
4
4
  export declare const PYTH_DEPENDENT_PROVIDERS: string[];
@@ -1,7 +1,8 @@
1
- import { executeEvmTransaction, executeSolanaTransaction } from '../../utils.js';
1
+ import { executeEvmTransaction, executeSolanaTransaction, executeTronTransaction, } from '../../utils.js';
2
2
  export const chainflipSwapper = {
3
3
  executeEvmTransaction,
4
4
  executeSolanaTransaction,
5
+ executeTronTransaction,
5
6
  executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => {
6
7
  return signAndBroadcastTransaction(txToSign);
7
8
  },
@@ -5,7 +5,7 @@ import type { SwapSource } from '../../types.js';
5
5
  import { ChainflipNetwork } from './types.js';
6
6
  export declare const CHAINFLIP_REGULAR_QUOTE: "regular";
7
7
  export declare const CHAINFLIP_DCA_QUOTE: "dca";
8
- export declare const ChainflipSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BitcoinMainnet, KnownChainIds.SolanaMainnet];
8
+ export declare const ChainflipSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BitcoinMainnet, KnownChainIds.SolanaMainnet, KnownChainIds.TronMainnet];
9
9
  export type ChainflipSupportedChainId = (typeof ChainflipSupportedChainIds)[number];
10
10
  export declare const ChainflipSupportedAssetIdsByChainId: Partial<Record<KnownChainIds, AssetId[]>>;
11
11
  export declare const chainIdToChainflipNetwork: Partial<Record<ChainId, ChainflipNetwork>>;
@@ -1,4 +1,4 @@
1
- import { arbitrumAssetId, btcAssetId, ethAssetId, flipAssetId, solAssetId, usdcAssetId, usdcOnArbitrumOneAssetId, usdcOnSolanaAssetId, usdtAssetId, usdtOnArbitrumOneAssetId, usdtOnSolanaAssetId, wbtcAssetId, } from '@shapeshiftoss/caip';
1
+ import { arbitrumAssetId, btcAssetId, ethAssetId, flipAssetId, solAssetId, tronAssetId, usdcAssetId, usdcOnArbitrumOneAssetId, usdcOnSolanaAssetId, usdtAssetId, usdtOnArbitrumOneAssetId, usdtOnSolanaAssetId, usdtOnTronAssetId, 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';
@@ -9,6 +9,7 @@ export const ChainflipSupportedChainIds = [
9
9
  KnownChainIds.ArbitrumMainnet,
10
10
  KnownChainIds.BitcoinMainnet,
11
11
  KnownChainIds.SolanaMainnet,
12
+ KnownChainIds.TronMainnet,
12
13
  ];
13
14
  export const ChainflipSupportedAssetIdsByChainId = {
14
15
  [KnownChainIds.EthereumMainnet]: [ethAssetId, flipAssetId, usdcAssetId, usdtAssetId, wbtcAssetId],
@@ -19,12 +20,14 @@ export const ChainflipSupportedAssetIdsByChainId = {
19
20
  ],
20
21
  [KnownChainIds.BitcoinMainnet]: [btcAssetId],
21
22
  [KnownChainIds.SolanaMainnet]: [solAssetId, usdcOnSolanaAssetId, usdtOnSolanaAssetId],
23
+ [KnownChainIds.TronMainnet]: [tronAssetId, usdtOnTronAssetId],
22
24
  };
23
25
  export const chainIdToChainflipNetwork = {
24
26
  [KnownChainIds.EthereumMainnet]: ChainflipNetwork.Ethereum,
25
27
  [KnownChainIds.ArbitrumMainnet]: ChainflipNetwork.Arbitrum,
26
28
  [KnownChainIds.BitcoinMainnet]: ChainflipNetwork.Bitcoin,
27
29
  [KnownChainIds.SolanaMainnet]: ChainflipNetwork.Solana,
30
+ [KnownChainIds.TronMainnet]: ChainflipNetwork.Tron,
28
31
  };
29
32
  export const CHAINFLIP_SWAP_SOURCE = SwapperName.Chainflip;
30
33
  export const CHAINFLIP_BOOST_SWAP_SOURCE = `${SwapperName.Chainflip} • Boost`;
@@ -1,6 +1,7 @@
1
1
  import { evm } from '@shapeshiftoss/chain-adapters';
2
2
  import { TxStatus } from '@shapeshiftoss/unchained-client';
3
3
  import { contractAddressOrUndefined } from '@shapeshiftoss/utils';
4
+ import { getTronTransactionFees } from '../../tron-utils/getTronTransactionFees.js';
4
5
  import { getExecutableTradeStep, isExecutableTradeQuote } from '../../utils.js';
5
6
  import { isNativeEvmAsset } from '../utils/helpers/helpers.js';
6
7
  import { ChainflipStatusMessage } from './constants.js';
@@ -163,6 +164,25 @@ export const chainflipApi = {
163
164
  const ratio = simulatedUnits > 0 ? boostedUnits / simulatedUnits : 1;
164
165
  return String(Math.ceil(Number(fast.txFee) * ratio));
165
166
  },
167
+ getUnsignedTronTransaction: ({ stepIndex, tradeQuote, from, assertGetTronChainAdapter }) => {
168
+ if (!isExecutableTradeQuote(tradeQuote))
169
+ throw new Error('Unable to execute a trade rate quote');
170
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
171
+ const { accountNumber, chainflipSpecific, sellAsset } = step;
172
+ if (!chainflipSpecific?.chainflipDepositAddress)
173
+ throw Error('Missing deposit address');
174
+ if (!chainflipSpecific?.chainflipSwapId)
175
+ throw Error('Missing swap id');
176
+ const adapter = assertGetTronChainAdapter(sellAsset.chainId);
177
+ return adapter.buildSendApiTransaction({
178
+ to: chainflipSpecific.chainflipDepositAddress,
179
+ from,
180
+ value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
181
+ accountNumber,
182
+ chainSpecific: { contractAddress: contractAddressOrUndefined(sellAsset.assetId) },
183
+ });
184
+ },
185
+ getTronTransactionFees,
166
186
  checkTradeStatus: async ({ config, swap }) => {
167
187
  const chainflipSwapId = swap?.metadata.chainflipSwapId;
168
188
  if (chainflipSwapId == null)
@@ -12,5 +12,6 @@ export declare enum ChainflipNetwork {
12
12
  Bitcoin = "Bitcoin",
13
13
  Ethereum = "Ethereum",
14
14
  Arbitrum = "Arbitrum",
15
- Solana = "Solana"
15
+ Solana = "Solana",
16
+ Tron = "Tron"
16
17
  }
@@ -4,4 +4,5 @@ export var ChainflipNetwork;
4
4
  ChainflipNetwork["Ethereum"] = "Ethereum";
5
5
  ChainflipNetwork["Arbitrum"] = "Arbitrum";
6
6
  ChainflipNetwork["Solana"] = "Solana";
7
+ ChainflipNetwork["Tron"] = "Tron";
7
8
  })(ChainflipNetwork || (ChainflipNetwork = {}));
@@ -1,5 +1,5 @@
1
1
  export declare const chainflipService: {
2
- get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
3
- post: <T = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
4
- delete: <T = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any>) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T>, import("../../../index.js").SwapErrorRight>>;
2
+ get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../../index.js").SwapErrorRight>>;
3
+ post: <T_1 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_1, any, {}>, import("../../../index.js").SwapErrorRight>>;
4
+ delete: <T_2 = any>(url: string, data: any, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T_2, any, {}>, import("../../../index.js").SwapErrorRight>>;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import { CHAIN_NAMESPACE, fromAssetId, solAssetId } from '@shapeshiftoss/caip';
2
- import { assertUnreachable, BigAmount, bnOrZero } from '@shapeshiftoss/utils';
2
+ import { assertUnreachable, BigAmount, bnOrZero, contractAddressOrUndefined, } from '@shapeshiftoss/utils';
3
3
  import { Err, Ok } from '@sniptt/monads';
4
4
  import { v4 as uuid } from 'uuid';
5
5
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
@@ -67,11 +67,14 @@ export const getQuoteOrRate = async (input, deps) => {
67
67
  if (maybeQuoteResponse.isErr()) {
68
68
  const error = maybeQuoteResponse.unwrapErr();
69
69
  const cause = error.cause;
70
- if (cause?.message?.includes('code 400') &&
71
- cause?.response?.data?.detail?.includes('Amount outside asset bounds')) {
70
+ // Chainflip returns a 400 with `errors.minimalAmountNative` when the sell amount is below the
71
+ // route minimum. The `detail` wording varies ("Amount outside asset bounds", "Amount below
72
+ // minimum. Min: ..."), so key off the field rather than string-matching the message.
73
+ const minAmountCryptoBaseUnit = cause?.response?.data?.errors?.minimalAmountNative?.[0];
74
+ if (cause?.response?.status === 400 && minAmountCryptoBaseUnit !== undefined) {
72
75
  return Err(createTradeAmountTooSmallErr({
73
76
  assetId: sellAsset.assetId,
74
- minAmountCryptoBaseUnit: cause.response?.data?.errors?.minimalAmountNative?.[0],
77
+ minAmountCryptoBaseUnit,
75
78
  }));
76
79
  }
77
80
  return Err(makeSwapErrorRight({
@@ -119,6 +122,21 @@ export const getQuoteOrRate = async (input, deps) => {
119
122
  const { fast } = await sellAdapter.getFeeData(getFeeDataInput);
120
123
  return { networkFeeCryptoBaseUnit: fast.txFee };
121
124
  }
125
+ case CHAIN_NAMESPACE.Tron: {
126
+ if (!input.sendAddress)
127
+ return { networkFeeCryptoBaseUnit: undefined };
128
+ const sellAdapter = deps.assertGetTronChainAdapter(sellAsset.chainId);
129
+ const { fast } = await sellAdapter.getFeeData({
130
+ // Simulates a self-send, since we don't know the 'to' just yet at this stage
131
+ to: input.sendAddress,
132
+ value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
133
+ chainSpecific: {
134
+ from: input.sendAddress,
135
+ contractAddress: contractAddressOrUndefined(sellAsset.assetId),
136
+ },
137
+ });
138
+ return { networkFeeCryptoBaseUnit: fast.txFee };
139
+ }
122
140
  default:
123
141
  throw new Error('Unsupported chainNamespace');
124
142
  }
@@ -182,6 +200,8 @@ export const getQuoteOrRate = async (input, deps) => {
182
200
  return 10;
183
201
  case CHAIN_NAMESPACE.Solana:
184
202
  return 0;
203
+ case CHAIN_NAMESPACE.Tron:
204
+ return 0;
185
205
  default:
186
206
  throw new Error('Unsupported chainNamespace');
187
207
  }
@@ -228,7 +248,7 @@ export const getQuoteOrRate = async (input, deps) => {
228
248
  buyAsset,
229
249
  sellAsset,
230
250
  accountNumber,
231
- allowanceContract: '0x0', // Chainflip does not use contracts
251
+ allowanceContract: '0x0',
232
252
  estimatedExecutionTimeMs: (singleQuoteResponse.boostQuote.estimatedDurationsSeconds?.deposit ?? 0) +
233
253
  (singleQuoteResponse.boostQuote.estimatedDurationsSeconds?.swap ?? 0) * 1000,
234
254
  chainflipSpecific: {
@@ -286,7 +306,7 @@ export const getQuoteOrRate = async (input, deps) => {
286
306
  buyAsset,
287
307
  sellAsset,
288
308
  accountNumber,
289
- allowanceContract: '0x0', // Chainflip does not use contracts - all Txs are sends
309
+ allowanceContract: '0x0',
290
310
  estimatedExecutionTimeMs: ((singleQuoteResponse.estimatedDurationsSeconds?.deposit ?? 0) +
291
311
  (singleQuoteResponse.estimatedDurationsSeconds?.swap ?? 0)) *
292
312
  1000,
@@ -5,5 +5,5 @@ type GetUtxoTxFeesInput = {
5
5
  sellAdapter: UtxoChainAdapter;
6
6
  pubKey: string | undefined;
7
7
  };
8
- export declare const getUtxoTxFees: ({ sellAmountCryptoBaseUnit, sellAdapter, pubKey, }: GetUtxoTxFeesInput) => Promise<Omit<QuoteFeeData, "protocolFees">>;
8
+ export declare const getUtxoTxFees: ({ sellAmountCryptoBaseUnit, sellAdapter, pubKey, }: GetUtxoTxFeesInput) => Promise<Omit<QuoteFeeData, 'protocolFees'>>;
9
9
  export {};
@@ -3,7 +3,6 @@ import type { Asset } from '@shapeshiftoss/types';
3
3
  import type { Result } from '@sniptt/monads';
4
4
  import type { AxiosResponse } from 'axios';
5
5
  import type { SwapErrorRight } from '../../../types.js';
6
- import type { ChainflipSupportedChainId } from '../constants.js';
7
6
  import type { ChainflipBaasSwapDepositAddress } from '../models/index.js';
8
7
  type ChainFlipBrokerBaseArgs = {
9
8
  brokerUrl: string;
@@ -21,8 +20,8 @@ type GetChainFlipSwapArgs = ChainFlipBrokerBaseArgs & {
21
20
  numberOfChunks?: number;
22
21
  chunkIntervalBlocks?: number;
23
22
  };
24
- export declare const isSupportedChainId: (chainId: ChainId) => chainId is ChainflipSupportedChainId;
25
- export declare const isSupportedAssetId: (chainId: ChainId, assetId: AssetId) => chainId is ChainflipSupportedChainId;
23
+ export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BitcoinMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet | import("@shapeshiftoss/types").KnownChainIds.TronMainnet;
24
+ export declare const isSupportedAssetId: (chainId: ChainId, assetId: AssetId) => chainId is import("@shapeshiftoss/types").KnownChainIds.EthereumMainnet | import("@shapeshiftoss/types").KnownChainIds.ArbitrumMainnet | import("@shapeshiftoss/types").KnownChainIds.BitcoinMainnet | import("@shapeshiftoss/types").KnownChainIds.SolanaMainnet | import("@shapeshiftoss/types").KnownChainIds.TronMainnet;
26
25
  export declare const calculateChainflipMinPrice: ({ sellAmountIncludingProtocolFeesCryptoBaseUnit, buyAmountAfterFeesCryptoBaseUnit, slippageTolerancePercentageDecimal, sellAsset, buyAsset, }: {
27
26
  sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
28
27
  buyAmountAfterFeesCryptoBaseUnit: string;
@@ -45,7 +45,8 @@ export const getChainFlipSwap = ({ brokerUrl, apiKey, sourceAsset, destinationAs
45
45
  swapUrl += `&numberOfChunks=${numberOfChunks}`;
46
46
  swapUrl += `&chunkIntervalBlocks=${chunkIntervalBlocks}`;
47
47
  }
48
- return chainflipService.get(swapUrl);
48
+ // Opening a deposit channel can spike past the default 10s timeout (notably on Tron).
49
+ return chainflipService.get(swapUrl, { timeout: 30_000 });
49
50
  };
50
51
  const fetchChainFlipAssets = async ({ brokerUrl, }) => {
51
52
  const result = await chainflipService.get(`${brokerUrl}/assets`);
@@ -100,7 +100,7 @@ export async function getCowSwapTradeQuote(input, config) {
100
100
  allowanceContract: COW_SWAP_VAULT_RELAYER_ADDRESS,
101
101
  rate,
102
102
  feeData: {
103
- networkFeeCryptoBaseUnit: '0', // no miner fee for CowSwap
103
+ networkFeeCryptoBaseUnit: '0',
104
104
  protocolFees: {
105
105
  [sellAsset.assetId]: {
106
106
  amountCryptoBaseUnit: feeAmountInSellTokenCryptoBaseUnit,