@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
@@ -306,8 +306,8 @@ const expectedTradeQuoteSmallAmountWethToFox = {
306
306
  networkFeeCryptoBaseUnit: '0',
307
307
  },
308
308
  sellAmountIncludingProtocolFeesCryptoBaseUnit: '1000000000000',
309
- buyAmountBeforeFeesCryptoBaseUnit: '166441655297153832879', // ~166 FOX
310
- buyAmountAfterFeesCryptoBaseUnit: '144293027591563571150', // ~144 FOX
309
+ buyAmountBeforeFeesCryptoBaseUnit: '166441655297153832879',
310
+ buyAmountAfterFeesCryptoBaseUnit: '144293027591563571150',
311
311
  source: SwapperName.CowSwap,
312
312
  buyAsset: FOX_MAINNET,
313
313
  sellAsset: WETH,
@@ -339,7 +339,7 @@ describe('getCowSwapTradeQuote', () => {
339
339
  affiliateBps: '0',
340
340
  supportsEIP1559: false,
341
341
  allowMultiHop: false,
342
- slippageTolerancePercentageDecimal: '0.005', // 0.5%
342
+ slippageTolerancePercentageDecimal: '0.005',
343
343
  quoteOrRate: 'quote',
344
344
  };
345
345
  const maybeTradeQuote = await getCowSwapTradeQuote(input, MOCK_COWSWAP_CONFIG);
@@ -363,7 +363,7 @@ describe('getCowSwapTradeQuote', () => {
363
363
  affiliateBps: '0',
364
364
  supportsEIP1559: false,
365
365
  allowMultiHop: false,
366
- slippageTolerancePercentageDecimal: '0.005', // 0.5%
366
+ slippageTolerancePercentageDecimal: '0.005',
367
367
  quoteOrRate: 'quote',
368
368
  };
369
369
  mockedCowService.post.mockReturnValue(Promise.resolve(Ok({
@@ -396,7 +396,7 @@ describe('getCowSwapTradeQuote', () => {
396
396
  affiliateBps: '0',
397
397
  supportsEIP1559: false,
398
398
  allowMultiHop: false,
399
- slippageTolerancePercentageDecimal: '0.005', // 0.5%
399
+ slippageTolerancePercentageDecimal: '0.005',
400
400
  quoteOrRate: 'quote',
401
401
  };
402
402
  mockedCowService.post.mockReturnValue(Promise.resolve(Ok({
@@ -429,7 +429,7 @@ describe('getCowSwapTradeQuote', () => {
429
429
  affiliateBps: '0',
430
430
  supportsEIP1559: false,
431
431
  allowMultiHop: false,
432
- slippageTolerancePercentageDecimal: '0.005', // 0.5%
432
+ slippageTolerancePercentageDecimal: '0.005',
433
433
  quoteOrRate: 'quote',
434
434
  };
435
435
  mockedCowService.post.mockReturnValue(Promise.resolve(Ok({
@@ -462,7 +462,7 @@ describe('getCowSwapTradeQuote', () => {
462
462
  affiliateBps: '0',
463
463
  supportsEIP1559: false,
464
464
  allowMultiHop: false,
465
- slippageTolerancePercentageDecimal: '0.005', // 0.5%
465
+ slippageTolerancePercentageDecimal: '0.005',
466
466
  quoteOrRate: 'quote',
467
467
  };
468
468
  mockedCowService.post.mockReturnValue(Promise.resolve(Ok({
@@ -495,7 +495,7 @@ describe('getCowSwapTradeQuote', () => {
495
495
  affiliateBps: '0',
496
496
  supportsEIP1559: false,
497
497
  allowMultiHop: false,
498
- slippageTolerancePercentageDecimal: '0.005', // 0.5%
498
+ slippageTolerancePercentageDecimal: '0.005',
499
499
  quoteOrRate: 'quote',
500
500
  };
501
501
  mockedCowService.post.mockReturnValue(Promise.resolve(Ok({
@@ -100,7 +100,7 @@ export async function getCowSwapTradeRate(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,
@@ -1,6 +1,6 @@
1
1
  import type { AxiosRequestConfig } from 'axios';
2
2
  export declare const cowService: {
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
  };
@@ -13,9 +13,9 @@ describe('utils', () => {
13
13
  const mockDay = '2020-12-31';
14
14
  const mockTime = 'T23:59:59.000Z';
15
15
  const mockDate = `${mockDay}${mockTime}`;
16
- beforeEach(() => vi
17
- .useFakeTimers()
18
- .setSystemTime(new Date(mockDate)));
16
+ beforeEach(() => {
17
+ vi.useFakeTimers().setSystemTime(new Date(mockDate));
18
+ });
19
19
  afterEach(() => {
20
20
  vi.restoreAllMocks();
21
21
  vi.useRealTimers();
@@ -1,5 +1,5 @@
1
1
  export declare const debridgeService: {
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,3 +1,4 @@
1
1
  export declare const ONE_CLICK_BASE_URL = "https://1click.chaindefuser.com";
2
2
  export declare const DEFAULT_SLIPPAGE_BPS = 50;
3
3
  export declare const DEFAULT_QUOTE_DEADLINE_MS: number;
4
+ export declare const BTC_QUOTE_DEADLINE_MS: number;
@@ -1,3 +1,4 @@
1
1
  export const ONE_CLICK_BASE_URL = 'https://1click.chaindefuser.com';
2
2
  export const DEFAULT_SLIPPAGE_BPS = 50;
3
3
  export const DEFAULT_QUOTE_DEADLINE_MS = 30 * 60 * 1000;
4
+ export const BTC_QUOTE_DEADLINE_MS = 60 * 60 * 1000;
@@ -1,4 +1,4 @@
1
- import { CHAIN_NAMESPACE, fromAssetId, nearChainId } from '@shapeshiftoss/caip';
1
+ import { btcChainId, CHAIN_NAMESPACE, fromAssetId, nearChainId } from '@shapeshiftoss/caip';
2
2
  import { evm } from '@shapeshiftoss/chain-adapters';
3
3
  import { bn, bnOrZero, chainIdToFeeAssetId, contractAddressOrUndefined, DAO_TREASURY_NEAR, isToken, } from '@shapeshiftoss/utils';
4
4
  import { Err, Ok } from '@sniptt/monads';
@@ -8,7 +8,7 @@ import { SwapperName, TradeQuoteError } from '../../../types.js';
8
8
  import { createTradeAmountTooSmallErr, getInputOutputRate, makeSwapErrorRight, } from '../../../utils.js';
9
9
  import { buildAffiliateFee } from '../../utils/affiliateFee.js';
10
10
  import { isNativeEvmAsset } from '../../utils/helpers/helpers.js';
11
- import { DEFAULT_QUOTE_DEADLINE_MS, DEFAULT_SLIPPAGE_BPS } from '../constants.js';
11
+ import { BTC_QUOTE_DEADLINE_MS, DEFAULT_QUOTE_DEADLINE_MS, DEFAULT_SLIPPAGE_BPS, } from '../constants.js';
12
12
  import { QuoteRequest } from '../types.js';
13
13
  import { assetToNearIntentsAsset, calculateAccountCreationCosts } from '../utils/helpers/helpers.js';
14
14
  import { ApiError, initializeOneClickService, OneClickService } from '../utils/oneClickService.js';
@@ -49,6 +49,9 @@ export const getTradeQuote = async (input, deps) => {
49
49
  message: `Asset ${buyAsset.symbol} on ${buyAsset.networkName || buyAsset.chainId} is not supported by NEAR Intents`,
50
50
  }));
51
51
  }
52
+ const quoteDeadline = sellAsset.chainId === btcChainId || buyAsset.chainId === btcChainId
53
+ ? BTC_QUOTE_DEADLINE_MS
54
+ : DEFAULT_QUOTE_DEADLINE_MS;
52
55
  const quoteRequest = {
53
56
  dry: false,
54
57
  swapType: QuoteRequest.swapType.EXACT_INPUT,
@@ -63,7 +66,7 @@ export const getTradeQuote = async (input, deps) => {
63
66
  refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
64
67
  recipient: receiveAddress,
65
68
  recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN,
66
- deadline: new Date(Date.now() + DEFAULT_QUOTE_DEADLINE_MS).toISOString(),
69
+ deadline: new Date(Date.now() + quoteDeadline).toISOString(),
67
70
  referral: 'shapeshift',
68
71
  appFees: [
69
72
  {
@@ -256,7 +259,7 @@ export const getTradeQuote = async (input, deps) => {
256
259
  steps: [
257
260
  {
258
261
  accountNumber,
259
- allowanceContract: quote.depositAddress,
262
+ allowanceContract: '',
260
263
  buyAmountBeforeFeesCryptoBaseUnit: quote.amountOut,
261
264
  buyAmountAfterFeesCryptoBaseUnit: quote.amountOut,
262
265
  buyAsset,
@@ -8,5 +8,5 @@ export declare const getNearIntentsAsset: ({ nearNetwork, contractAddress, }: {
8
8
  contractAddress: string;
9
9
  }) => string;
10
10
  export declare const assetToNearIntentsAsset: (asset: Asset) => Promise<string | null>;
11
- export declare const mapNearIntentsStatus: (status: GetExecutionStatusResponse["status"]) => TxStatus;
12
- export declare const getNearIntentsStatusMessage: (status: GetExecutionStatusResponse["status"]) => string | undefined;
11
+ export declare const mapNearIntentsStatus: (status: GetExecutionStatusResponse['status']) => TxStatus;
12
+ export declare const getNearIntentsStatusMessage: (status: GetExecutionStatusResponse['status']) => string | undefined;
@@ -45,6 +45,7 @@ export const getNearIntentsAsset = ({ nearNetwork, contractAddress, }) => {
45
45
  const NEP245_CHAINS = ['bsc', 'pol', 'avax', 'op', 'tron', 'monad', 'plasma'];
46
46
  const TOKEN_LOOKUP_CHAINS = ['sui', 'starknet', 'ton'];
47
47
  const NEAR_CHAIN = 'near';
48
+ const BTC_CHAIN = 'btc';
48
49
  const WNEAR_CONTRACT_ADDRESS = 'wrap.near';
49
50
  const isNep245Chain = (chain) => {
50
51
  return NEP245_CHAINS.includes(chain);
@@ -56,6 +57,9 @@ export const assetToNearIntentsAsset = async (asset) => {
56
57
  const nearNetwork = chainIdToNearIntentsChain[asset.chainId];
57
58
  if (!nearNetwork)
58
59
  return null;
60
+ // https://partners.near-intents.org/omni-migration#partners
61
+ if (nearNetwork === BTC_CHAIN)
62
+ return `1cs_v1:btc:native:coin`;
59
63
  // NEAR chain requires special handling
60
64
  // Native NEAR maps to wNEAR (wrap.near)
61
65
  if (nearNetwork === NEAR_CHAIN) {
@@ -91,7 +95,7 @@ export const assetToNearIntentsAsset = async (asset) => {
91
95
  }
92
96
  return match.assetId;
93
97
  }
94
- // NEP-141 chains (ETH, ARB, BASE, GNOSIS, BTC, DOGE): use predictable format
98
+ // NEP-141 chains (ETH, ARB, BASE, GNOSIS, DOGE): use predictable format
95
99
  const contractAddress = isToken(asset.assetId)
96
100
  ? fromAssetId(asset.assetId).assetReference
97
101
  : zeroAddress;
@@ -79,14 +79,14 @@ export async function getPortalsTradeRate(input, assertGetEvmChainAdapter, swapp
79
79
  // Use full quote endpoint (not estimate) to get transaction data for Tenderly simulation
80
80
  // Skip validation since this is just a rate quote
81
81
  const quoteResponse = await fetchPortalsTradeOrder({
82
- sender: RATE_DUMMY_ADDRESS, // Dummy address for rates (no wallet yet)
82
+ sender: RATE_DUMMY_ADDRESS,
83
83
  inputToken,
84
84
  outputToken,
85
85
  inputAmount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
86
86
  slippageTolerancePercentage: userSlippageTolerancePercentageDecimalOrDefault,
87
87
  partner: getTreasuryAddressFromChainId(chainId),
88
88
  feePercentage: affiliateBpsPercentage,
89
- validate: false, // Skip Portals' simulation validation
89
+ validate: false,
90
90
  swapperConfig,
91
91
  });
92
92
  if (!quoteResponse.tx) {
@@ -1,4 +1,4 @@
1
1
  import type { ChainId } from '@shapeshiftoss/caip';
2
2
  import type { PortalsSupportedChainId } from '../types.js';
3
- export declare const isSupportedChainId: (chainId: ChainId) => chainId is PortalsSupportedChainId;
3
+ export declare const isSupportedChainId: (chainId: ChainId) => chainId is import("@shapeshiftoss/types").KnownChainIds;
4
4
  export declare const getPortalsRouterAddressByChainId: (chainId: PortalsSupportedChainId) => string;
@@ -1,45 +1,7 @@
1
- import { abstractChainId, arbitrumChainId, avalancheChainId, baseChainId, berachainChainId, blastChainId, bobChainId, bscChainId, btcChainId, celoChainId, cronosChainId, ethChainId, etherealChainId, flowEvmChainId, gnosisChainId, hemiChainId, hyperEvmChainId, inkChainId, katanaChainId, lineaChainId, mantleChainId, megaethChainId, modeChainId, monadChainId, optimismChainId, plasmaChainId, plumeChainId, polygonChainId, scrollChainId, seiChainId, solanaChainId, soneiumChainId, sonicChainId, storyChainId, tronChainId, unichainChainId, worldChainChainId, zkSyncEraChainId } from '@shapeshiftoss/caip';
2
1
  import { TradeQuoteError } from '../../types.js';
3
2
  import { RelayErrorCode } from './utils/types.js';
4
3
  export declare const chainIdToRelayChainId: {
5
- [btcChainId]: number;
6
- [ethChainId]: 1;
7
- [arbitrumChainId]: 42161;
8
- [baseChainId]: 8453;
9
- [optimismChainId]: 10;
10
- [polygonChainId]: 137;
11
- [solanaChainId]: number;
12
- [gnosisChainId]: 100;
13
- [avalancheChainId]: 43114;
14
- [bscChainId]: 56;
15
- [tronChainId]: number;
16
- [monadChainId]: 143;
17
- [hyperEvmChainId]: 999;
18
- [mantleChainId]: 5000;
19
- [inkChainId]: 57073;
20
- [megaethChainId]: number;
21
- [plasmaChainId]: 9745;
22
- [katanaChainId]: 747474;
23
- [etherealChainId]: number;
24
- [celoChainId]: 42220;
25
- [flowEvmChainId]: 747;
26
- [plumeChainId]: 98866;
27
- [storyChainId]: 1514;
28
- [zkSyncEraChainId]: 324;
29
- [blastChainId]: 81457;
30
- [worldChainChainId]: 480;
31
- [hemiChainId]: 43111;
32
- [lineaChainId]: 59144;
33
- [berachainChainId]: 80094;
34
- [scrollChainId]: 534352;
35
- [cronosChainId]: 25;
36
- [sonicChainId]: 146;
37
- [unichainChainId]: 130;
38
- [bobChainId]: 60808;
39
- [modeChainId]: 34443;
40
- [soneiumChainId]: 1868;
41
- [seiChainId]: 1329;
42
- [abstractChainId]: number;
4
+ [x: string]: number;
43
5
  };
44
6
  export declare enum RelayStatusMessage {
45
7
  WaitingForDeposit = "Waiting for deposit...",
@@ -68,7 +68,7 @@ export const relayErrorCodeToTradeQuoteError = {
68
68
  [RelayErrorCode.ChainDisabled]: TradeQuoteError.TradingHalted,
69
69
  [RelayErrorCode.Erc20RouterAddressNotFound]: TradeQuoteError.UnsupportedTradePair,
70
70
  [RelayErrorCode.ExtraTransactionsNotSupported]: TradeQuoteError.UnsupportedTradePair,
71
- [RelayErrorCode.InsufficientFunds]: TradeQuoteError.SellAmountBelowTradeFee,
71
+ [RelayErrorCode.InsufficientFunds]: TradeQuoteError.InsufficientFunds,
72
72
  [RelayErrorCode.InsufficientLiquidity]: TradeQuoteError.SellAmountBelowTradeFee,
73
73
  [RelayErrorCode.InvalidAddress]: TradeQuoteError.UnsupportedTradePair,
74
74
  [RelayErrorCode.InvalidExtraTransactions]: TradeQuoteError.UnsupportedTradePair,
@@ -2,4 +2,4 @@ import type { Result } from '@sniptt/monads';
2
2
  import type { AxiosResponse } from 'axios';
3
3
  import type { SwapErrorRight, SwapperConfig } from '../../../types.js';
4
4
  import type { RelayFetchQuoteParams, RelayQuote } from './types.js';
5
- export declare const fetchRelayTrade: <T extends "quote" | "rate">(params: RelayFetchQuoteParams<T>, config: SwapperConfig) => Promise<Result<AxiosResponse<RelayQuote, any>, SwapErrorRight>>;
5
+ export declare const fetchRelayTrade: <T extends "rate" | "quote">(params: RelayFetchQuoteParams<T>, config: SwapperConfig) => Promise<Result<AxiosResponse<RelayQuote, any>, SwapErrorRight>>;
@@ -1,5 +1,5 @@
1
1
  export declare const relayService: {
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
  };
@@ -2,23 +2,14 @@ import { tronAssetId, tronChainId } from '@shapeshiftoss/caip';
2
2
  import { toAddressNList } from '@shapeshiftoss/chain-adapters';
3
3
  import { TxStatus } from '@shapeshiftoss/unchained-client';
4
4
  import { TronWeb } from 'tronweb';
5
- import { getTronTransactionFees } from '../../tron-utils/getTronTransactionFees.js';
6
5
  import { createDefaultStatusResponse, getExecutableTradeStep, isExecutableTradeQuote, } from '../../utils.js';
7
6
  import { getSunioTradeQuote } from './getSunioTradeQuote/getSunioTradeQuote.js';
8
7
  import { getSunioTradeRate } from './getSunioTradeRate/getSunioTradeRate.js';
8
+ import { buildSwapExactInputParameters, SUNIO_SWAP_EXACT_INPUT_SELECTOR, } from './utils/buildSwapContractCall.js';
9
9
  import { buildSwapRouteParameters } from './utils/buildSwapRouteParameters.js';
10
10
  import { SUNIO_SMART_ROUTER_CONTRACT } from './utils/constants.js';
11
+ import { getSunioTransactionFees } from './utils/getSunioTransactionFees.js';
11
12
  const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
12
- const convertAddressesToEvmFormat = (value) => {
13
- if (Array.isArray(value)) {
14
- return value.map(v => convertAddressesToEvmFormat(v));
15
- }
16
- if (typeof value === 'string' && value.startsWith('T') && TronWeb.isAddress(value)) {
17
- const hex = TronWeb.address.toHex(value);
18
- return hex.replace(/^41/, '0x');
19
- }
20
- return value;
21
- };
22
13
  export const sunioApi = {
23
14
  getTradeQuote: async (input, deps) => {
24
15
  const maybeTradeQuote = await getSunioTradeQuote(input, deps);
@@ -29,7 +20,7 @@ export const sunioApi = {
29
20
  return maybeTradeRate.map(rate => [rate]);
30
21
  },
31
22
  getUnsignedTronTransaction: async (args) => {
32
- const { tradeQuote, stepIndex, from, slippageTolerancePercentageDecimal, assertGetTronChainAdapter, } = args;
23
+ const { tradeQuote, stepIndex, from, slippageTolerancePercentageDecimal, assertGetTronChainAdapter, config, } = args;
33
24
  if (!isExecutableTradeQuote(tradeQuote)) {
34
25
  throw new Error('Unable to execute a trade rate quote');
35
26
  }
@@ -42,24 +33,12 @@ export const sunioApi = {
42
33
  const rpcUrl = adapter.httpProvider.getRpcUrl();
43
34
  const tronWeb = new TronWeb({
44
35
  fullHost: rpcUrl,
36
+ headers: config.VITE_TRON_GRID_API_KEY
37
+ ? { 'TRON-PRO-API-KEY': config.VITE_TRON_GRID_API_KEY }
38
+ : {},
45
39
  });
46
40
  const routeParams = buildSwapRouteParameters(sunioMetadata.route, step.sellAmountIncludingProtocolFeesCryptoBaseUnit, step.buyAmountAfterFeesCryptoBaseUnit, tradeQuote.receiveAddress, slippageTolerancePercentageDecimal);
47
- const parameters = [
48
- { type: 'address[]', value: routeParams.path },
49
- { type: 'string[]', value: routeParams.poolVersion },
50
- { type: 'uint256[]', value: routeParams.versionLen },
51
- { type: 'uint24[]', value: routeParams.fees },
52
- {
53
- type: 'tuple(uint256,uint256,address,uint256)',
54
- value: convertAddressesToEvmFormat([
55
- routeParams.swapData.amountIn,
56
- routeParams.swapData.amountOutMin,
57
- routeParams.swapData.recipient,
58
- routeParams.swapData.deadline,
59
- ]),
60
- },
61
- ];
62
- const functionSelector = 'swapExactInput(address[],string[],uint256[],uint24[],(uint256,uint256,address,uint256))';
41
+ const parameters = buildSwapExactInputParameters(routeParams);
63
42
  const isSellingNativeTrx = step.sellAsset.assetId === tronAssetId;
64
43
  const callValue = isSellingNativeTrx
65
44
  ? Number(step.sellAmountIncludingProtocolFeesCryptoBaseUnit)
@@ -68,7 +47,7 @@ export const sunioApi = {
68
47
  feeLimit: 100_000_000,
69
48
  callValue,
70
49
  };
71
- const txData = await tronWeb.transactionBuilder.triggerSmartContract(SUNIO_SMART_ROUTER_CONTRACT, functionSelector, options, parameters, from);
50
+ const txData = await tronWeb.transactionBuilder.triggerSmartContract(SUNIO_SMART_ROUTER_CONTRACT, SUNIO_SWAP_EXACT_INPUT_SELECTOR, options, parameters, from);
72
51
  if (!txData.result || !txData.result.result) {
73
52
  throw new Error('[Sun.io] Failed to build swap transaction');
74
53
  }
@@ -97,7 +76,7 @@ export const sunioApi = {
97
76
  transaction,
98
77
  };
99
78
  },
100
- getTronTransactionFees,
79
+ getTronTransactionFees: getSunioTransactionFees,
101
80
  checkTradeStatus: async ({ txHash, assertGetTronChainAdapter }) => {
102
81
  try {
103
82
  // Wait for TronGrid indexing to avoid false "REVERT"
@@ -108,12 +87,16 @@ export const sunioApi = {
108
87
  return createDefaultStatusResponse(txHash);
109
88
  }
110
89
  const contractRet = tx.ret?.[0]?.contractRet;
111
- // Only mark as confirmed if SUCCESS AND has confirmations (in a block)
112
- const status = contractRet === 'SUCCESS' && tx.confirmations > 0
113
- ? TxStatus.Confirmed
114
- : contractRet === 'REVERT'
115
- ? TxStatus.Failed
116
- : TxStatus.Pending;
90
+ // Tron reports many failure codes (REVERT, OUT_OF_ENERGY, OUT_OF_TIME, ...). A missing
91
+ // contractRet means it isn't mined yet; any non-SUCCESS value is a terminal failure.
92
+ const status = (() => {
93
+ if (!contractRet)
94
+ return TxStatus.Pending;
95
+ if (contractRet === 'SUCCESS') {
96
+ return tx.confirmations > 0 ? TxStatus.Confirmed : TxStatus.Pending;
97
+ }
98
+ return TxStatus.Failed;
99
+ })();
117
100
  return {
118
101
  status,
119
102
  buyTxHash: txHash,
@@ -0,0 +1,6 @@
1
+ import type { SwapRouteParameters } from './buildSwapRouteParameters.js';
2
+ export declare const SUNIO_SWAP_EXACT_INPUT_SELECTOR = "swapExactInput(address[],string[],uint256[],uint24[],(uint256,uint256,address,uint256))";
3
+ export declare const buildSwapExactInputParameters: (routeParams: SwapRouteParameters) => {
4
+ type: string;
5
+ value: unknown;
6
+ }[];
@@ -0,0 +1,29 @@
1
+ import { TronWeb } from 'tronweb';
2
+ export const SUNIO_SWAP_EXACT_INPUT_SELECTOR = 'swapExactInput(address[],string[],uint256[],uint24[],(uint256,uint256,address,uint256))';
3
+ const convertAddressesToEvmFormat = (value) => {
4
+ if (Array.isArray(value)) {
5
+ return value.map(v => convertAddressesToEvmFormat(v));
6
+ }
7
+ if (typeof value === 'string' && value.startsWith('T') && TronWeb.isAddress(value)) {
8
+ const hex = TronWeb.address.toHex(value);
9
+ return hex.replace(/^41/, '0x');
10
+ }
11
+ return value;
12
+ };
13
+ // Parameter list for the SmartExchangeRouter swapExactInput call, shared between fee
14
+ // estimation and execution so both encode the call identically.
15
+ export const buildSwapExactInputParameters = (routeParams) => [
16
+ { type: 'address[]', value: routeParams.path },
17
+ { type: 'string[]', value: routeParams.poolVersion },
18
+ { type: 'uint256[]', value: routeParams.versionLen },
19
+ { type: 'uint24[]', value: routeParams.fees },
20
+ {
21
+ type: 'tuple(uint256,uint256,address,uint256)',
22
+ value: convertAddressesToEvmFormat([
23
+ routeParams.swapData.amountIn,
24
+ routeParams.swapData.amountOutMin,
25
+ routeParams.swapData.recipient,
26
+ routeParams.swapData.deadline,
27
+ ]),
28
+ },
29
+ ];
@@ -2,12 +2,12 @@ import { bn } from '@shapeshiftoss/utils';
2
2
  export const buildSwapRouteParameters = (route, sellAmountCryptoBaseUnit, minBuyAmountCryptoBaseUnit, recipient, slippageTolerancePercentageDecimal) => {
3
3
  const path = route.tokens;
4
4
  const poolVersion = route.poolVersions;
5
- const versionLen = poolVersion.map((_, index) => {
6
- if (index === poolVersion.length - 1) {
7
- return path.length - index;
8
- }
9
- return 2;
10
- });
5
+ // The SmartExchangeRouter expects sum(versionLen) === path.length: the first
6
+ // pool segment consumes 2 tokens (input + output) and each subsequent pool
7
+ // reuses the previous output, consuming 1 new token. This relies on the Sun.io
8
+ // API returning poolVersions per-hop (poolVersions.length === tokens.length - 1),
9
+ // which it does — the router also accepts this un-collapsed form for same-version hops.
10
+ const versionLen = poolVersion.map((_, index) => (index === 0 ? 2 : 1));
11
11
  const fees = route.poolFees.map(fee => Number(fee));
12
12
  const amountOutWithSlippage = bn(minBuyAmountCryptoBaseUnit)
13
13
  .times(bn(1).minus(slippageTolerancePercentageDecimal))
@@ -2,5 +2,7 @@ export declare const SUNIO_SUPPORTED_CHAIN_IDS: readonly [import("@shapeshiftoss
2
2
  export declare const SUNIO_API_BASE_URL = "https://rot.endjgfsv.link";
3
3
  export declare const SUNIO_SMART_ROUTER_CONTRACT: "TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj";
4
4
  export declare const DEFAULT_SLIPPAGE_PERCENTAGE = "0.005";
5
+ export declare const SUNIO_FALLBACK_SWAP_ENERGY_NATIVE = 215000;
6
+ export declare const SUNIO_FALLBACK_SWAP_ENERGY_TRC20 = 375000;
5
7
  export declare const SUNIO_DEX_TYPES: "PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3";
6
8
  export declare const SUNIO_TRON_NATIVE_ADDRESS: "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb";
@@ -8,6 +8,12 @@ export const SUNIO_API_BASE_URL = 'https://rot.endjgfsv.link';
8
8
  // This is the current mainnet router that sun.io's frontend uses
9
9
  export const SUNIO_SMART_ROUTER_CONTRACT = 'TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj';
10
10
  export const DEFAULT_SLIPPAGE_PERCENTAGE = '0.005';
11
+ // Energy fallbacks for when we can't simulate a swap (no address, or the simulation reverts
12
+ // pre-approval for TRC20 sells). Set to observed average energy so the 1.2x margin applied at
13
+ // estimate time lifts them to cover the worst case (native ~245k, TRC20 ~415k due to the extra
14
+ // transferFrom token pull) without double-counting safety.
15
+ export const SUNIO_FALLBACK_SWAP_ENERGY_NATIVE = 215_000;
16
+ export const SUNIO_FALLBACK_SWAP_ENERGY_TRC20 = 375_000;
11
17
  export const SUNIO_DEX_TYPES = 'PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3';
12
18
  // Native TRX token address (used when assetId is not a TRC-20 token)
13
19
  export const SUNIO_TRON_NATIVE_ADDRESS = 'T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb';
@@ -0,0 +1,12 @@
1
+ import type { SunioRoute } from '../types.js';
2
+ type EstimateSunioNetworkFeeArgs = {
3
+ rpcUrl: string;
4
+ apiKey: string;
5
+ route: SunioRoute;
6
+ sellAmountCryptoBaseUnit: string;
7
+ isSellingNativeTrx: boolean;
8
+ address: string | undefined;
9
+ slippageTolerancePercentageDecimal: string | undefined;
10
+ };
11
+ export declare const estimateSunioNetworkFeeCryptoBaseUnit: ({ rpcUrl, apiKey, route, sellAmountCryptoBaseUnit, isSellingNativeTrx, address, slippageTolerancePercentageDecimal, }: EstimateSunioNetworkFeeArgs) => Promise<string>;
12
+ export {};
@@ -0,0 +1,74 @@
1
+ import { bn } from '@shapeshiftoss/utils';
2
+ import { TronWeb } from 'tronweb';
3
+ import { buildSwapExactInputParameters, SUNIO_SWAP_EXACT_INPUT_SELECTOR, } from './buildSwapContractCall.js';
4
+ import { buildSwapRouteParameters } from './buildSwapRouteParameters.js';
5
+ import { DEFAULT_SLIPPAGE_PERCENTAGE, SUNIO_FALLBACK_SWAP_ENERGY_NATIVE, SUNIO_FALLBACK_SWAP_ENERGY_TRC20, SUNIO_SMART_ROUTER_CONTRACT, SUNIO_TRON_NATIVE_ADDRESS, } from './constants.js';
6
+ // Estimates the network fee (in TRX base units) for a Sun.io swap. The router sponsors only ~1%
7
+ // of energy (origin_energy_usage); the user pays the rest, so we simulate the real swapExactInput
8
+ // call when we have an address to estimate from. The simulation reverts before approval for TRC20
9
+ // sells (and when the account lacks the sell balance), so we fall back to a conservative per-sell-
10
+ // type constant. Used both at quote time and re-run at confirm time, where a now-granted allowance
11
+ // lets the simulation produce the true cost.
12
+ export const estimateSunioNetworkFeeCryptoBaseUnit = async ({ rpcUrl, apiKey, route, sellAmountCryptoBaseUnit, isSellingNativeTrx, address, slippageTolerancePercentageDecimal, }) => {
13
+ const tronGridHeaders = apiKey ? { 'TRON-PRO-API-KEY': apiKey } : {};
14
+ const tronWeb = new TronWeb({ fullHost: rpcUrl, headers: tronGridHeaders });
15
+ // Live network prices, defaulting if the node is unavailable so we still produce a fee
16
+ const { bandwidthPrice, energyPrice } = await (async () => {
17
+ try {
18
+ const params = await tronWeb.trx.getChainParameters();
19
+ return {
20
+ bandwidthPrice: params.find(p => p.key === 'getTransactionFee')?.value ?? 1000,
21
+ energyPrice: params.find(p => p.key === 'getEnergyFee')?.value ?? 100,
22
+ };
23
+ }
24
+ catch {
25
+ return { bandwidthPrice: 1000, energyPrice: 100 };
26
+ }
27
+ })();
28
+ // Account activation (1 TRX) is only charged when the recipient receives native TRX, mirroring
29
+ // the chain adapter. A TRC20 buy doesn't incur the flat activation fee (its account-creation
30
+ // cost is folded into energy). Only checkable with an address.
31
+ const isBuyingNativeTrx = route.tokens[route.tokens.length - 1] === SUNIO_TRON_NATIVE_ADDRESS;
32
+ const accountActivationFee = await (async () => {
33
+ if (!address || !isBuyingNativeTrx)
34
+ return 0;
35
+ try {
36
+ const recipientInfoResponse = await fetch(`${rpcUrl}/wallet/getaccount`, {
37
+ method: 'POST',
38
+ headers: { 'Content-Type': 'application/json', ...tronGridHeaders },
39
+ body: JSON.stringify({ address, visible: true }),
40
+ });
41
+ const recipientInfo = await recipientInfoResponse.json();
42
+ const recipientExists = recipientInfo && Object.keys(recipientInfo).length > 1;
43
+ return recipientExists ? 0 : 1_000_000; // 1 TRX
44
+ }
45
+ catch {
46
+ return 0;
47
+ }
48
+ })();
49
+ const energyUsed = await (async () => {
50
+ // TRC20 sells cost far more energy than native sells (the extra transferFrom token pull)
51
+ const fallbackEnergy = isSellingNativeTrx
52
+ ? SUNIO_FALLBACK_SWAP_ENERGY_NATIVE
53
+ : SUNIO_FALLBACK_SWAP_ENERGY_TRC20;
54
+ if (!address)
55
+ return fallbackEnergy;
56
+ try {
57
+ const routeParams = buildSwapRouteParameters(route, sellAmountCryptoBaseUnit, '0', address, slippageTolerancePercentageDecimal ?? DEFAULT_SLIPPAGE_PERCENTAGE);
58
+ const callValue = isSellingNativeTrx ? Number(sellAmountCryptoBaseUnit) : 0;
59
+ const result = await tronWeb.transactionBuilder.triggerConstantContract(SUNIO_SMART_ROUTER_CONTRACT, SUNIO_SWAP_EXACT_INPUT_SELECTOR, { callValue }, buildSwapExactInputParameters(routeParams), address);
60
+ // A reverted simulation (e.g. TRC20 sell pre-approval) can still return a small energy_used;
61
+ // only trust it when the call actually succeeded, otherwise use the conservative fallback.
62
+ if (result?.result?.result !== true || result.energy_used == null)
63
+ return fallbackEnergy;
64
+ return result.energy_used;
65
+ }
66
+ catch {
67
+ return fallbackEnergy;
68
+ }
69
+ })();
70
+ // 1.2x safety margin for energy price/usage variance between estimate and execution
71
+ const energyFee = Math.ceil(energyUsed * energyPrice * 1.2);
72
+ const bandwidthFee = 1100 * bandwidthPrice;
73
+ return bn(energyFee).plus(bandwidthFee).plus(accountActivationFee).toFixed(0);
74
+ };