@shapeshiftoss/swapper 17.7.2 → 17.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/constants.js +35 -26
  3. package/dist/cjs/index.d.ts +1 -0
  4. package/dist/cjs/index.js +8 -17
  5. package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
  6. package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +2 -1
  7. package/dist/cjs/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
  8. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.js +2 -2
  9. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
  10. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeRate/getTradeRate.js +2 -1
  11. package/dist/cjs/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
  12. package/dist/cjs/swappers/AvnuSwapper/endpoints.js +2 -2
  13. package/dist/cjs/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
  14. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +2 -1
  15. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +11 -6
  16. package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +4 -11
  17. package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +12 -15
  18. package/dist/cjs/swappers/BebopSwapper/types.d.ts +65 -79
  19. package/dist/cjs/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
  20. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -18
  21. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +49 -82
  22. package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
  23. package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
  24. package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.js +8 -0
  25. package/dist/cjs/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
  26. package/dist/cjs/swappers/BobGatewaySwapper/endpoints.js +143 -0
  27. package/dist/cjs/swappers/BobGatewaySwapper/index.d.ts +3 -0
  28. package/dist/cjs/swappers/BobGatewaySwapper/index.js +22 -0
  29. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
  30. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +90 -0
  31. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
  32. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +73 -0
  33. package/dist/cjs/swappers/BobGatewaySwapper/types.d.ts +20 -0
  34. package/dist/cjs/swappers/BobGatewaySwapper/types.js +2 -0
  35. package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
  36. package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.js +31 -0
  37. package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
  38. package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.js +314 -0
  39. package/dist/cjs/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +9 -19
  40. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
  41. package/dist/cjs/swappers/ButterSwap/test-data/routeQuote.js +4 -4
  42. package/dist/cjs/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
  43. package/dist/cjs/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
  44. package/dist/cjs/swappers/ButterSwap/xhr.js +4 -4
  45. package/dist/cjs/swappers/CetusSwapper/utils/constants.d.ts +1 -1
  46. package/dist/cjs/swappers/ChainflipSwapper/ChainflipSwapper.js +1 -0
  47. package/dist/cjs/swappers/ChainflipSwapper/constants.d.ts +1 -1
  48. package/dist/cjs/swappers/ChainflipSwapper/constants.js +3 -0
  49. package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +20 -0
  50. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteBoostQuote.js +5 -4
  51. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteEstimatedDurationsSeconds.js +5 -4
  52. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuote.js +5 -5
  53. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasQuoteQuoteFee.js +5 -5
  54. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusChunkInfo.js +5 -4
  55. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusDca.js +5 -4
  56. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusEgress.js +5 -4
  57. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasStatusSwap.js +5 -4
  58. package/dist/cjs/swappers/ChainflipSwapper/models/ChainflipBaasSwapDepositAddress.js +5 -4
  59. package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +2 -1
  60. package/dist/cjs/swappers/ChainflipSwapper/types.js +1 -0
  61. package/dist/cjs/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
  62. package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +25 -5
  63. package/dist/cjs/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
  64. package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
  65. package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.js +2 -1
  66. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +3 -2
  67. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
  68. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +3 -2
  69. package/dist/cjs/swappers/CowSwapper/utils/cowService.d.ts +3 -3
  70. package/dist/cjs/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
  71. package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
  72. package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +2 -1
  73. package/dist/cjs/swappers/NearIntentsSwapper/constants.d.ts +1 -0
  74. package/dist/cjs/swappers/NearIntentsSwapper/constants.js +2 -1
  75. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +5 -2
  76. package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
  77. package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
  78. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +2 -1
  79. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +4 -3
  80. package/dist/cjs/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
  81. package/dist/cjs/swappers/RelaySwapper/constant.d.ts +1 -39
  82. package/dist/cjs/swappers/RelaySwapper/constant.js +1 -1
  83. package/dist/cjs/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
  84. package/dist/cjs/swappers/RelaySwapper/utils/getRelayPsbtRelayer.js +7 -17
  85. package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +2 -1
  86. package/dist/cjs/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
  87. package/dist/cjs/swappers/SunioSwapper/endpoints.js +19 -36
  88. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
  89. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.js +33 -0
  90. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
  91. package/dist/cjs/swappers/SunioSwapper/utils/constants.d.ts +2 -0
  92. package/dist/cjs/swappers/SunioSwapper/utils/constants.js +7 -1
  93. package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
  94. package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +78 -0
  95. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +18 -75
  96. package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
  97. package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.js +36 -0
  98. package/dist/cjs/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
  99. package/dist/cjs/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
  100. package/dist/cjs/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
  101. package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +8 -18
  102. package/dist/cjs/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +8 -18
  103. package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
  104. package/dist/cjs/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
  105. package/dist/cjs/swappers/ThorchainSwapper/utils/longTailHelpers.js +2 -2
  106. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +2 -1
  107. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.test.js +7 -17
  108. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +2 -1
  109. package/dist/cjs/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
  110. package/dist/cjs/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
  111. package/dist/cjs/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
  112. package/dist/cjs/swappers/utils/helpers/helpers.js +1 -0
  113. package/dist/cjs/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
  114. package/dist/cjs/thorchain-utils/checkTradeStatus.js +8 -1
  115. package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
  116. package/dist/cjs/thorchain-utils/cosmossdk/getThorTxData.js +19 -0
  117. package/dist/cjs/thorchain-utils/cosmossdk/index.d.ts +1 -0
  118. package/dist/cjs/thorchain-utils/cosmossdk/index.js +1 -0
  119. package/dist/cjs/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
  120. package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +51 -33
  121. package/dist/cjs/thorchain-utils/getQuote.js +27 -29
  122. package/dist/cjs/thorchain-utils/index.d.ts +1 -0
  123. package/dist/cjs/thorchain-utils/index.js +19 -18
  124. package/dist/cjs/thorchain-utils/parseBuyTxHash.d.ts +1 -1
  125. package/dist/cjs/thorchain-utils/service.d.ts +3 -3
  126. package/dist/cjs/thorchain-utils/tron/getTronTransactionFees.js +8 -5
  127. package/dist/cjs/thorchain-utils/types.d.ts +1 -1
  128. package/dist/cjs/tron-utils/getTronTransactionFees.d.ts +1 -1
  129. package/dist/cjs/types.d.ts +16 -3
  130. package/dist/cjs/types.js +5 -0
  131. package/dist/cjs/utils/tenderly/storageSlots.js +20 -20
  132. package/dist/cjs/utils.d.ts +4 -4
  133. package/dist/esm/.tsbuildinfo +1 -1
  134. package/dist/esm/constants.js +9 -0
  135. package/dist/esm/index.d.ts +1 -0
  136. package/dist/esm/index.js +1 -0
  137. package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +3 -3
  138. package/dist/esm/swappers/ArbitrumBridgeSwapper/endpoints.d.ts +3 -3
  139. package/dist/esm/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
  140. package/dist/esm/swappers/ArbitrumBridgeSwapper/utils/fetchArbitrumBridgeSwap.d.ts +2 -2
  141. package/dist/esm/swappers/AvnuSwapper/endpoints.js +2 -2
  142. package/dist/esm/swappers/AvnuSwapper/utils/constants.d.ts +1 -1
  143. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +10 -6
  144. package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +2 -10
  145. package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +11 -15
  146. package/dist/esm/swappers/BebopSwapper/types.d.ts +65 -79
  147. package/dist/esm/swappers/BebopSwapper/utils/bebopService.d.ts +1 -1
  148. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +2 -18
  149. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +45 -76
  150. package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -2
  151. package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
  152. package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.js +5 -0
  153. package/dist/esm/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
  154. package/dist/esm/swappers/BobGatewaySwapper/endpoints.js +140 -0
  155. package/dist/esm/swappers/BobGatewaySwapper/index.d.ts +3 -0
  156. package/dist/esm/swappers/BobGatewaySwapper/index.js +3 -0
  157. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
  158. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +86 -0
  159. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
  160. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +69 -0
  161. package/dist/esm/swappers/BobGatewaySwapper/types.d.ts +20 -0
  162. package/dist/esm/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
  163. package/dist/esm/swappers/BobGatewaySwapper/utils/constants.js +27 -0
  164. package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
  165. package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.js +299 -0
  166. package/dist/esm/swappers/ButterSwap/swapperApi/checkTradeStatus.test.js +2 -2
  167. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +1 -1
  168. package/dist/esm/swappers/ButterSwap/test-data/routeQuote.js +4 -4
  169. package/dist/esm/swappers/ButterSwap/utils/butterSwapHistoryService.d.ts +3 -3
  170. package/dist/esm/swappers/ButterSwap/utils/butterSwapService.d.ts +3 -3
  171. package/dist/esm/swappers/CetusSwapper/utils/constants.d.ts +1 -1
  172. package/dist/esm/swappers/ChainflipSwapper/ChainflipSwapper.js +2 -1
  173. package/dist/esm/swappers/ChainflipSwapper/constants.d.ts +1 -1
  174. package/dist/esm/swappers/ChainflipSwapper/constants.js +4 -1
  175. package/dist/esm/swappers/ChainflipSwapper/endpoints.js +20 -0
  176. package/dist/esm/swappers/ChainflipSwapper/types.d.ts +2 -1
  177. package/dist/esm/swappers/ChainflipSwapper/types.js +1 -0
  178. package/dist/esm/swappers/ChainflipSwapper/utils/chainflipService.d.ts +3 -3
  179. package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +26 -6
  180. package/dist/esm/swappers/ChainflipSwapper/utils/getUtxoTxFees.d.ts +1 -1
  181. package/dist/esm/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -3
  182. package/dist/esm/swappers/ChainflipSwapper/utils/helpers.js +2 -1
  183. package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -1
  184. package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +8 -8
  185. package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +1 -1
  186. package/dist/esm/swappers/CowSwapper/utils/cowService.d.ts +3 -3
  187. package/dist/esm/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
  188. package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.d.ts +3 -3
  189. package/dist/esm/swappers/NearIntentsSwapper/constants.d.ts +1 -0
  190. package/dist/esm/swappers/NearIntentsSwapper/constants.js +1 -0
  191. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +7 -4
  192. package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.d.ts +2 -2
  193. package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +5 -1
  194. package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +2 -2
  195. package/dist/esm/swappers/PortalsSwapper/utils/helpers.d.ts +1 -1
  196. package/dist/esm/swappers/RelaySwapper/constant.d.ts +1 -39
  197. package/dist/esm/swappers/RelaySwapper/constant.js +1 -1
  198. package/dist/esm/swappers/RelaySwapper/utils/fetchRelayTrade.d.ts +1 -1
  199. package/dist/esm/swappers/RelaySwapper/utils/relayService.d.ts +3 -3
  200. package/dist/esm/swappers/SunioSwapper/endpoints.js +19 -36
  201. package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
  202. package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.js +29 -0
  203. package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
  204. package/dist/esm/swappers/SunioSwapper/utils/constants.d.ts +2 -0
  205. package/dist/esm/swappers/SunioSwapper/utils/constants.js +6 -0
  206. package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
  207. package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +74 -0
  208. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +16 -74
  209. package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
  210. package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.js +32 -0
  211. package/dist/esm/swappers/SunioSwapper/utils/helpers/helpers.d.ts +1 -2
  212. package/dist/esm/swappers/SunioSwapper/utils/sunioService.d.ts +3 -3
  213. package/dist/esm/swappers/ThorchainSwapper/getTradeQuote/getTradeQuote.test.js +10 -0
  214. package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailQuote.js +1 -1
  215. package/dist/esm/swappers/ThorchainSwapper/utils/getL1ToLongtailRate.js +1 -1
  216. package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailQuote.js +1 -1
  217. package/dist/esm/swappers/ThorchainSwapper/utils/getLongtailRate.js +1 -1
  218. package/dist/esm/swappers/ZrxSwapper/utils/fetchFromZrx.js +2 -2
  219. package/dist/esm/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +3 -2
  220. package/dist/esm/swappers/ZrxSwapper/utils/zrxService.d.ts +1 -1
  221. package/dist/esm/swappers/utils/helpers/helpers.js +2 -1
  222. package/dist/esm/swappers/utils/test-data/cryptoMarketDataById.d.ts +1 -35
  223. package/dist/esm/thorchain-utils/checkTradeStatus.js +8 -1
  224. package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.d.ts +12 -0
  225. package/dist/esm/thorchain-utils/cosmossdk/getThorTxData.js +15 -0
  226. package/dist/esm/thorchain-utils/cosmossdk/index.d.ts +1 -0
  227. package/dist/esm/thorchain-utils/cosmossdk/index.js +1 -0
  228. package/dist/esm/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
  229. package/dist/esm/thorchain-utils/getL1RateOrQuote.js +44 -16
  230. package/dist/esm/thorchain-utils/getQuote.js +27 -29
  231. package/dist/esm/thorchain-utils/index.d.ts +1 -0
  232. package/dist/esm/thorchain-utils/index.js +11 -1
  233. package/dist/esm/thorchain-utils/parseBuyTxHash.d.ts +1 -1
  234. package/dist/esm/thorchain-utils/service.d.ts +3 -3
  235. package/dist/esm/thorchain-utils/tron/getTronTransactionFees.js +8 -5
  236. package/dist/esm/thorchain-utils/types.d.ts +1 -1
  237. package/dist/esm/tron-utils/getTronTransactionFees.d.ts +1 -1
  238. package/dist/esm/types.d.ts +16 -3
  239. package/dist/esm/types.js +5 -0
  240. package/dist/esm/utils/tenderly/storageSlots.js +20 -20
  241. package/dist/esm/utils.d.ts +4 -4
  242. package/package.json +8 -7
  243. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
  244. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -57
  245. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -11
  246. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -40
  247. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -94
  248. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
  249. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -53
  250. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -11
  251. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -34
  252. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts +0 -1
  253. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -92
  254. /package/dist/{cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts → esm/swappers/BobGatewaySwapper/types.js} +0 -0
@@ -1,11 +1,11 @@
1
1
  import { tronChainId } from '@shapeshiftoss/caip';
2
2
  import { BigAmount, bn, contractAddressOrUndefined } from '@shapeshiftoss/utils';
3
3
  import { Err, Ok } from '@sniptt/monads';
4
- import { TronWeb } from 'tronweb';
5
4
  import { SwapperName, TradeQuoteError } from '../../../types.js';
6
5
  import { getInputOutputRate, makeSwapErrorRight } from '../../../utils.js';
7
6
  import { buildAffiliateFee } from '../../utils/affiliateFee.js';
8
7
  import { DEFAULT_SLIPPAGE_PERCENTAGE, SUNIO_SMART_ROUTER_CONTRACT } from './constants.js';
8
+ import { estimateSunioNetworkFeeCryptoBaseUnit } from './estimateSunioNetworkFee.js';
9
9
  import { fetchSunioQuote } from './fetchFromSunio.js';
10
10
  import { isSupportedChainId } from './helpers/helpers.js';
11
11
  import { sunioServiceFactory } from './sunioService.js';
@@ -57,83 +57,25 @@ export async function getQuoteOrRate(input, deps) {
57
57
  code: TradeQuoteError.InternalError,
58
58
  }));
59
59
  }
60
- // Fetch network fees for both quotes and rates (when wallet connected)
61
- let networkFeeCryptoBaseUnit = undefined;
62
- // Estimate fees when we have an address to estimate from
63
- if (receiveAddress) {
60
+ const networkFeeCryptoBaseUnit = await (async () => {
64
61
  try {
65
- const contractAddress = contractAddressOrUndefined(sellAsset.assetId);
66
- const isSellingNativeTrx = !contractAddress;
67
- const tronWeb = new TronWeb({ fullHost: deps.config.VITE_TRON_NODE_URL });
68
- // Get chain parameters for pricing
69
- const params = await tronWeb.trx.getChainParameters();
70
- const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
71
- const energyPrice = params.find(p => p.key === 'getEnergyFee')?.value ?? 100;
72
- // Check if recipient needs activation (applies to all swaps)
73
- let accountActivationFee = 0;
74
- try {
75
- const recipientInfoResponse = await fetch(`${deps.config.VITE_TRON_NODE_URL}/wallet/getaccount`, {
76
- method: 'POST',
77
- headers: { 'Content-Type': 'application/json' },
78
- body: JSON.stringify({ address: receiveAddress, visible: true }),
79
- });
80
- const recipientInfo = await recipientInfoResponse.json();
81
- const recipientExists = recipientInfo && Object.keys(recipientInfo).length > 1;
82
- if (!recipientExists) {
83
- accountActivationFee = 1_000_000; // 1 TRX
84
- }
85
- }
86
- catch {
87
- // Ignore activation check errors
88
- }
89
- // For native TRX swaps, Sun.io uses a contract call with value
90
- // We need to estimate energy for the swap contract, not just bandwidth
91
- if (isSellingNativeTrx) {
92
- try {
93
- // Sun.io contract owner provides most energy (~117k), users only pay ~2k
94
- // Use fixed 2k energy estimate instead of querying (which returns total 120k)
95
- const energyUsed = 2000; // User pays ~2k energy, contract covers the rest
96
- const energyFee = energyUsed * energyPrice; // No multiplier - contract provides energy
97
- // Estimate bandwidth for contract call (much larger than simple transfer)
98
- const bandwidthFee = 1100 * bandwidthPrice; // ~1100 bytes for contract call (with safety buffer)
99
- networkFeeCryptoBaseUnit = bn(energyFee)
100
- .plus(bandwidthFee)
101
- .plus(accountActivationFee)
102
- .toFixed(0);
103
- }
104
- catch (estimationError) {
105
- // Fallback estimate: ~2k energy + ~1100 bytes bandwidth + activation fee
106
- const fallbackEnergyFee = 2000 * energyPrice;
107
- const fallbackBandwidthFee = 1100 * bandwidthPrice;
108
- networkFeeCryptoBaseUnit = bn(fallbackEnergyFee)
109
- .plus(fallbackBandwidthFee)
110
- .plus(accountActivationFee)
111
- .toFixed(0);
112
- }
113
- }
114
- else {
115
- // For TRC-20 swaps through Sun.io router
116
- // Same as TRX: contract owner provides most energy, user pays ~2k
117
- // Sun.io provides ~217k energy, user pays ~2k
118
- const energyFee = 2000 * energyPrice;
119
- const bandwidthFee = 1100 * bandwidthPrice;
120
- networkFeeCryptoBaseUnit = bn(energyFee)
121
- .plus(bandwidthFee)
122
- .plus(accountActivationFee)
123
- .toFixed(0);
124
- }
62
+ return await estimateSunioNetworkFeeCryptoBaseUnit({
63
+ rpcUrl: deps.config.VITE_TRON_NODE_URL,
64
+ apiKey: deps.config.VITE_TRON_GRID_API_KEY,
65
+ route: bestRoute,
66
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
67
+ isSellingNativeTrx: !contractAddressOrUndefined(sellAsset.assetId),
68
+ address: receiveAddress,
69
+ slippageTolerancePercentageDecimal,
70
+ });
125
71
  }
126
72
  catch (error) {
127
- // For rates, fall back to '0' on estimation failure
128
- // For quotes, let it error (required for accurate swap)
129
- if (!isQuote) {
130
- networkFeeCryptoBaseUnit = '0';
131
- }
132
- else {
133
- throw error;
134
- }
73
+ // For rates, fall back to '0' on unexpected failure; quotes require an accurate fee
74
+ if (!isQuote)
75
+ return '0';
76
+ throw error;
135
77
  }
136
- }
78
+ })();
137
79
  const buyAmountCryptoBaseUnit = BigAmount.fromPrecision({
138
80
  value: bestRoute.amountOut,
139
81
  precision: buyAsset.precision,
@@ -0,0 +1,2 @@
1
+ import type { GetUnsignedTronTransactionArgs } from '../../../types.js';
2
+ export declare const getSunioTransactionFees: ({ tradeQuote, stepIndex, from, slippageTolerancePercentageDecimal, assertGetTronChainAdapter, config, }: GetUnsignedTronTransactionArgs) => Promise<string>;
@@ -0,0 +1,32 @@
1
+ import { tronAssetId, tronChainId } from '@shapeshiftoss/caip';
2
+ import { getExecutableTradeStep, isExecutableTradeQuote } from '../../../utils.js';
3
+ import { estimateSunioNetworkFeeCryptoBaseUnit } from './estimateSunioNetworkFee.js';
4
+ export const getSunioTransactionFees = async ({ tradeQuote, stepIndex, from, slippageTolerancePercentageDecimal, assertGetTronChainAdapter, config, }) => {
5
+ if (!isExecutableTradeQuote(tradeQuote))
6
+ throw new Error('Unable to execute a trade rate quote');
7
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
8
+ const storedNetworkFeeCryptoBaseUnit = step.feeData.networkFeeCryptoBaseUnit;
9
+ const route = step.sunioTransactionMetadata?.route;
10
+ if (!route) {
11
+ if (!storedNetworkFeeCryptoBaseUnit)
12
+ throw new Error('Missing network fee in quote');
13
+ return storedNetworkFeeCryptoBaseUnit;
14
+ }
15
+ try {
16
+ const adapter = assertGetTronChainAdapter(tronChainId);
17
+ return await estimateSunioNetworkFeeCryptoBaseUnit({
18
+ rpcUrl: adapter.httpProvider.getRpcUrl(),
19
+ apiKey: config.VITE_TRON_GRID_API_KEY,
20
+ route,
21
+ sellAmountCryptoBaseUnit: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
22
+ isSellingNativeTrx: step.sellAsset.assetId === tronAssetId,
23
+ address: from,
24
+ slippageTolerancePercentageDecimal,
25
+ });
26
+ }
27
+ catch {
28
+ if (!storedNetworkFeeCryptoBaseUnit)
29
+ throw new Error('Missing network fee in quote');
30
+ return storedNetworkFeeCryptoBaseUnit;
31
+ }
32
+ };
@@ -1,5 +1,4 @@
1
1
  import type { AssetId } from '@shapeshiftoss/caip';
2
- import { tronChainId } from '@shapeshiftoss/caip';
3
2
  export declare const isSupportedChainId: (chainId: string) => boolean;
4
3
  export declare const assetIdToTronToken: (assetId: AssetId) => string;
5
- export declare const isTronChainId: (chainId: string) => chainId is typeof tronChainId;
4
+ export declare const isTronChainId: (chainId: string) => chainId is import("@shapeshiftoss/caip").ChainId;
@@ -1,6 +1,6 @@
1
1
  export declare const sunioServiceFactory: () => {
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
  };
6
6
  export type SunioService = ReturnType<typeof sunioServiceFactory>;
@@ -76,6 +76,11 @@ const expectedQuoteResponse = [
76
76
  thorchainSpecific: {
77
77
  maxStreamingQuantity: undefined,
78
78
  },
79
+ thorchainTransactionMetadata: {
80
+ to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
81
+ data: '0x',
82
+ value: '0',
83
+ },
79
84
  },
80
85
  ],
81
86
  },
@@ -119,6 +124,11 @@ const expectedQuoteResponse = [
119
124
  thorchainSpecific: {
120
125
  maxStreamingQuantity: undefined,
121
126
  },
127
+ thorchainTransactionMetadata: {
128
+ to: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
129
+ data: '0x',
130
+ value: '0',
131
+ },
122
132
  },
123
133
  ],
124
134
  },
@@ -101,7 +101,7 @@ export const getL1ToLongtailQuote = async (input, deps, streamingInterval, swapp
101
101
  // This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
102
102
  buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
103
103
  allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
104
- })), // assuming multi-hop quote steps here since we're mapping over quote steps,
104
+ })),
105
105
  isLongtail: true,
106
106
  longtailData: {
107
107
  L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
@@ -89,7 +89,7 @@ export const getL1ToLongtailRate = async (input, deps, streamingInterval, swappe
89
89
  // This is wrong, we should get the get the value before fees or display ETH value received after the thorchain bridge
90
90
  buyAmountBeforeFeesCryptoBaseUnit: quotedAmountOut.toString(),
91
91
  allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
92
- })), // assuming multi-hop rate steps here since we're mapping over quote steps,
92
+ })),
93
93
  isLongtail: true,
94
94
  longtailData: {
95
95
  L1ToLongtailExpectedAmountOut: quotedAmountOut.toString(),
@@ -55,7 +55,7 @@ export const getLongtailToL1Quote = async (input, deps, streamingInterval, swapp
55
55
  sellAmountIncludingProtocolFeesCryptoBaseUnit,
56
56
  sellAsset,
57
57
  allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
58
- })), // assuming multi-hop quote steps here since we're mapping over quote steps
58
+ })),
59
59
  isLongtail: true,
60
60
  longtailData: {
61
61
  longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
@@ -55,7 +55,7 @@ export const getLongtailToL1Rate = async (input, deps, streamingInterval, swappe
55
55
  sellAmountIncludingProtocolFeesCryptoBaseUnit,
56
56
  sellAsset,
57
57
  allowanceContract: TS_AGGREGATOR_TOKEN_TRANSFER_PROXY_CONTRACT_MAINNET,
58
- })), // assuming multi-hop quote steps here since we're mapping over quote steps
58
+ })),
59
59
  isLongtail: true,
60
60
  longtailData: {
61
61
  longtailToL1ExpectedAmountOut: quotedAmountOut.toString(),
@@ -24,9 +24,9 @@ const fetchFromZrx = async ({ quoteOrRate, buyAsset, sellAsset, sellAmountInclud
24
24
  sellAmount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
25
25
  taker: sellAddress,
26
26
  swapFeeBps: bn(affiliateBps).toNumber(),
27
- swapFeeToken: assetIdToZrxToken(buyAsset.assetId), // must be set to the buy asset to simplify fee calcs
27
+ swapFeeToken: assetIdToZrxToken(buyAsset.assetId),
28
28
  slippageBps: convertDecimalPercentageToBasisPoints(slippageTolerancePercentageDecimal).toNumber(),
29
- swapFeeRecipient: maybeTreasuryAddress, // Where affiliate fees are sent
29
+ swapFeeRecipient: maybeTreasuryAddress,
30
30
  feeRecipientTradeSurplus: maybeTreasuryAddress, // Where trade surplus is sent
31
31
  },
32
32
  });
@@ -1,9 +1,10 @@
1
1
  import type { AssetId, ChainId } from '@shapeshiftoss/caip';
2
2
  import type { Asset, AssetsByIdPartial } from '@shapeshiftoss/types';
3
- import type { ZrxFees, ZrxSupportedChainId } from '../../types.js';
3
+ import { KnownChainIds } from '@shapeshiftoss/types';
4
+ import type { ZrxFees } from '../../types.js';
4
5
  export declare const assetIdToZrxToken: (assetId: AssetId) => string;
5
6
  export declare const zrxTokenToAssetId: (token: string, chainId: ChainId) => AssetId;
6
- export declare const isSupportedChainId: (chainId: ChainId) => chainId is ZrxSupportedChainId;
7
+ export declare const isSupportedChainId: (chainId: ChainId) => chainId is KnownChainIds.EthereumMainnet | KnownChainIds.AvalancheMainnet | KnownChainIds.OptimismMainnet | KnownChainIds.BnbSmartChainMainnet | KnownChainIds.PolygonMainnet | KnownChainIds.ArbitrumMainnet | KnownChainIds.BaseMainnet;
7
8
  export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
8
9
  buyAsset: Asset;
9
10
  sellAsset: Asset;
@@ -4,6 +4,6 @@ import type { MonadicSwapperAxiosService } from '../../../types.js';
4
4
  type AxiosInstanceHoF = (instance: AxiosInstance, options?: Omit<RetryConfig, 'instance'>) => AxiosInstance;
5
5
  export declare const zrxServiceFactory: ({ baseUrl, wrapper, }: {
6
6
  baseUrl: string;
7
- wrapper?: AxiosInstanceHoF;
7
+ wrapper?: AxiosInstanceHoF | undefined;
8
8
  }) => MonadicSwapperAxiosService;
9
9
  export {};
@@ -1,6 +1,6 @@
1
1
  import { arbitrumAssetId, avalancheAssetId, baseAssetId, bscAssetId, ethAssetId, fromAssetId, gnosisAssetId, katanaAssetId, monadAssetId, optimismAssetId, plasmaAssetId, polygonAssetId, } from '@shapeshiftoss/caip';
2
2
  import { KnownChainIds } from '@shapeshiftoss/types';
3
- import { DAO_TREASURY_ARBITRUM, DAO_TREASURY_AVALANCHE, DAO_TREASURY_BASE, DAO_TREASURY_BITCOIN, DAO_TREASURY_BSC, DAO_TREASURY_ETHEREUM_MAINNET, DAO_TREASURY_GNOSIS, DAO_TREASURY_HYPEREVM, DAO_TREASURY_MONAD, DAO_TREASURY_OPTIMISM, DAO_TREASURY_POLYGON, DAO_TREASURY_SOLANA, DAO_TREASURY_STARKNET, DAO_TREASURY_TON, isTreasuryChainId, } from '@shapeshiftoss/utils';
3
+ import { DAO_TREASURY_ARBITRUM, DAO_TREASURY_AVALANCHE, DAO_TREASURY_BASE, DAO_TREASURY_BITCOIN, DAO_TREASURY_BOB, DAO_TREASURY_BSC, DAO_TREASURY_ETHEREUM_MAINNET, DAO_TREASURY_GNOSIS, DAO_TREASURY_HYPEREVM, DAO_TREASURY_MONAD, DAO_TREASURY_OPTIMISM, DAO_TREASURY_POLYGON, DAO_TREASURY_SOLANA, DAO_TREASURY_STARKNET, DAO_TREASURY_TON, isTreasuryChainId, } from '@shapeshiftoss/utils';
4
4
  export const isNativeEvmAsset = (assetId) => {
5
5
  const { chainId } = fromAssetId(assetId);
6
6
  switch (chainId) {
@@ -45,6 +45,7 @@ const DAO_TREASURY_BY_CHAIN_ID = {
45
45
  [KnownChainIds.TonMainnet]: DAO_TREASURY_TON,
46
46
  [KnownChainIds.MonadMainnet]: DAO_TREASURY_MONAD,
47
47
  [KnownChainIds.HyperEvmMainnet]: DAO_TREASURY_HYPEREVM,
48
+ [KnownChainIds.BobMainnet]: DAO_TREASURY_BOB,
48
49
  };
49
50
  export const getTreasuryAddressFromChainId = (chainId) => {
50
51
  const maybeTreasuryChainId = isTreasuryChainId(chainId) ? chainId : undefined;
@@ -1,39 +1,5 @@
1
- import { AVAX, BSC, BTC, ETH, FOX_GNOSIS, FOX_MAINNET, OPTIMISM, RUNE, USDC_GNOSIS, USDC_MAINNET, WBTC, WETH } from './assets.js';
2
1
  export declare const marketDataByAssetIdUsd: {
3
- [FOX_MAINNET.assetId]: {
4
- price: string;
5
- };
6
- [FOX_GNOSIS.assetId]: {
7
- price: string;
8
- };
9
- [ETH.assetId]: {
10
- price: string;
11
- };
12
- [AVAX.assetId]: {
13
- price: string;
14
- };
15
- [BSC.assetId]: {
16
- price: string;
17
- };
18
- [BTC.assetId]: {
19
- price: string;
20
- };
21
- [RUNE.assetId]: {
22
- price: string;
23
- };
24
- [OPTIMISM.assetId]: {
25
- price: string;
26
- };
27
- [USDC_MAINNET.assetId]: {
28
- price: string;
29
- };
30
- [USDC_GNOSIS.assetId]: {
31
- price: string;
32
- };
33
- [WBTC.assetId]: {
34
- price: string;
35
- };
36
- [WETH.assetId]: {
2
+ [x: string]: {
37
3
  price: string;
38
4
  };
39
5
  };
@@ -62,7 +62,14 @@ export const checkTradeStatus = async ({ txHash, chainId, address, fetchIsSmartC
62
62
  return { buyTxHash, status: TxStatus.Pending, message };
63
63
  }
64
64
  catch (e) {
65
- console.error(e);
65
+ const message = (() => {
66
+ if (axios.isAxiosError(e))
67
+ return e.response?.data?.message ?? e.message;
68
+ if (e instanceof Error)
69
+ return e.message;
70
+ return String(e);
71
+ })();
72
+ console.error(`checkTradeStatus(${nativeChain}, ${txHash}): ${message}`);
66
73
  return { buyTxHash: undefined, status: TxStatus.Unknown, message: undefined };
67
74
  }
68
75
  };
@@ -0,0 +1,12 @@
1
+ import type { Asset } from '@shapeshiftoss/types';
2
+ import type { SwapperConfig, SwapperName } from '../../types.js';
3
+ type GetThorTxDataArgs = {
4
+ sellAsset: Asset;
5
+ config: SwapperConfig;
6
+ swapperName: SwapperName;
7
+ };
8
+ type GetThorTxDataReturn = {
9
+ vault: string;
10
+ };
11
+ export declare const getThorTxData: ({ sellAsset, config, swapperName, }: GetThorTxDataArgs) => Promise<GetThorTxDataReturn>;
12
+ export {};
@@ -0,0 +1,15 @@
1
+ import { getInboundAddressDataForChain } from '../getInboundAddressDataForChain.js';
2
+ import { getChainIdBySwapper, getDaemonUrl } from '../index.js';
3
+ export const getThorTxData = async ({ sellAsset, config, swapperName, }) => {
4
+ // Native assets on the swapper's own chain (RUNE on THORChain, CACAO on MAYAChain)
5
+ // deposit via MsgDeposit and have no recipient address.
6
+ if (sellAsset.chainId === getChainIdBySwapper(swapperName))
7
+ return { vault: '' };
8
+ // Everything else (e.g. ATOM via THORChain, RUNE via MAYAChain) sends via MsgSend
9
+ // to the swapper's inbound vault on that chain.
10
+ const daemonUrl = getDaemonUrl(config, swapperName);
11
+ const res = await getInboundAddressDataForChain(daemonUrl, sellAsset.assetId, true, swapperName);
12
+ if (res.isErr())
13
+ throw res.unwrapErr();
14
+ return { vault: res.unwrap().address };
15
+ };
@@ -1 +1,2 @@
1
1
  export * from './getCosmosSdkTransactionFees.js';
2
+ export * from './getThorTxData.js';
@@ -1 +1,2 @@
1
1
  export * from './getCosmosSdkTransactionFees.js';
2
+ export * from './getThorTxData.js';
@@ -1,7 +1,7 @@
1
1
  import type { Asset } from '@shapeshiftoss/types';
2
2
  import type { SwapperConfig, SwapperName } from '../types.js';
3
3
  import type { ThorEvmTradeQuote } from './types.js';
4
- export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "vault" | "aggregator" | "data" | "memo" | "tradeType" | "expiry" | "longtailData" | "slippageTolerancePercentageDecimal"> & {
4
+ export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "data" | "slippageTolerancePercentageDecimal" | "memo" | "expiry" | "tradeType" | "aggregator" | "vault" | "longtailData"> & {
5
5
  sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
6
6
  config: SwapperConfig;
7
7
  sellAsset: Asset;
@@ -7,8 +7,10 @@ import { TronWeb } from 'tronweb';
7
7
  import { v4 as uuid } from 'uuid';
8
8
  import { getDefaultSlippageDecimalPercentageForSwapper } from '../index.js';
9
9
  import { buildAffiliateFee } from '../swappers/utils/affiliateFee.js';
10
+ import { isNativeEvmAsset } from '../swappers/utils/helpers/helpers.js';
10
11
  import { TradeQuoteError } from '../types.js';
11
12
  import { getInputOutputRate, makeSwapErrorRight } from '../utils.js';
13
+ import * as cosmossdk from './cosmossdk/index.js';
12
14
  import * as evm from './evm/index.js';
13
15
  import { getLimitWithManualSlippage } from './getLimitWithManualSlippage/getLimitWithManualSlippage.js';
14
16
  import { getQuote } from './getQuote.js';
@@ -102,7 +104,7 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
102
104
  const protocolFees = {};
103
105
  if (!buyAssetTradeFeeBuyAssetCryptoBaseUnit.isZero()) {
104
106
  protocolFees[buyAsset.assetId] = {
105
- amountCryptoBaseUnit: buyAssetTradeFeeBuyAssetCryptoBaseUnit.toString(),
107
+ amountCryptoBaseUnit: buyAssetTradeFeeBuyAssetCryptoBaseUnit.toFixed(0),
106
108
  requiresBalance: false,
107
109
  asset: buyAsset,
108
110
  };
@@ -128,12 +130,12 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
128
130
  affilate: getAffiliate(swapperName),
129
131
  });
130
132
  };
131
- const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, }) => {
133
+ const makeThorTradeRateOrQuote = ({ route, memo, allowanceContract, feeData, data, router, vault, thorchainTransactionMetadata, }) => {
132
134
  const buyAmountAfterFeesCryptoBaseUnit = convertPrecision({
133
135
  value: route.expectedAmountOutThorBaseUnit,
134
136
  inputExponent: buyAssetNativePrecision,
135
137
  outputExponent: buyAsset.precision,
136
- }).toFixed();
138
+ }).toFixed(0);
137
139
  const rate = getInputOutputRate({
138
140
  sellAmountCryptoBaseUnit,
139
141
  buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
@@ -182,6 +184,7 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
182
184
  thorchainSpecific: {
183
185
  maxStreamingQuantity: route.quote.max_streaming_quantity,
184
186
  },
187
+ thorchainTransactionMetadata,
185
188
  },
186
189
  ],
187
190
  };
@@ -213,6 +216,11 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
213
216
  data,
214
217
  router,
215
218
  vault,
219
+ thorchainTransactionMetadata: {
220
+ to: router,
221
+ data,
222
+ value: isNativeEvmAsset(sellAsset.assetId) ? sellAmountCryptoBaseUnit : '0',
223
+ },
216
224
  feeData: {
217
225
  protocolFees: getProtocolFees(route.quote),
218
226
  networkFeeCryptoBaseUnit,
@@ -258,8 +266,13 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
258
266
  })();
259
267
  return makeThorTradeRateOrQuote({
260
268
  route,
261
- allowanceContract: '0x0', // not applicable to UTXOs
269
+ allowanceContract: '0x0',
262
270
  memo,
271
+ thorchainTransactionMetadata: {
272
+ to: vault,
273
+ memo,
274
+ value: sellAmountCryptoBaseUnit,
275
+ },
263
276
  feeData,
264
277
  });
265
278
  }));
@@ -275,11 +288,18 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
275
288
  case CHAIN_NAMESPACE.CosmosSdk: {
276
289
  const cosmosChainAdapter = assertGetCosmosSdkChainAdapter(sellAsset.chainId);
277
290
  const { fast } = await cosmosChainAdapter.getFeeData({});
291
+ const { vault } = await cosmossdk.getThorTxData({ sellAsset, config, swapperName });
278
292
  return Ok(perRouteValues.map((route) => {
293
+ const memo = getMemo(route);
279
294
  return makeThorTradeRateOrQuote({
280
295
  route,
281
- memo: getMemo(route),
282
- allowanceContract: '0x0', // not applicable to cosmossdk
296
+ memo,
297
+ allowanceContract: '0x0',
298
+ thorchainTransactionMetadata: {
299
+ to: vault,
300
+ memo,
301
+ value: sellAmountCryptoBaseUnit,
302
+ },
283
303
  feeData: {
284
304
  networkFeeCryptoBaseUnit: fast.txFee,
285
305
  protocolFees: getProtocolFees(route.quote),
@@ -293,13 +313,13 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
293
313
  case CHAIN_NAMESPACE.Solana: {
294
314
  const adapter = assertGetSolanaChainAdapter(sellAsset.chainId);
295
315
  const sendAddress = input.sendAddress;
316
+ const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
296
317
  const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
297
318
  const memo = getMemo(route);
298
319
  const protocolFees = getProtocolFees(route.quote);
299
320
  const feeData = await (async () => {
300
321
  if (!sendAddress)
301
322
  return { networkFeeCryptoBaseUnit: undefined, protocolFees };
302
- const { vault } = await solana.getThorTxData({ sellAsset, config, swapperName });
303
323
  const memoInstruction = new TransactionInstruction({
304
324
  keys: [],
305
325
  programId: new PublicKey(SOLANA_MEMO_PROGRAM_ID),
@@ -325,6 +345,11 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
325
345
  route,
326
346
  allowanceContract: '0x0',
327
347
  memo,
348
+ thorchainTransactionMetadata: {
349
+ to: vault,
350
+ memo,
351
+ value: sellAmountCryptoBaseUnit,
352
+ },
328
353
  feeData,
329
354
  });
330
355
  }));
@@ -338,23 +363,21 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
338
363
  return Ok(routes);
339
364
  }
340
365
  case CHAIN_NAMESPACE.Tron: {
366
+ const { vault } = await tron.getThorTxData({ sellAsset, config, swapperName });
341
367
  const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
342
368
  const memo = getMemo(route);
343
369
  let networkFeeCryptoBaseUnit = undefined;
344
370
  // Calculate fees for rates when we have a receive address (wallet connected)
345
- if (input.quoteOrRate === 'rate' && input.receiveAddress) {
371
+ if (input.quoteOrRate === 'rate' && input.receiveAddress && vault) {
346
372
  try {
347
373
  const { sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
348
374
  const contractAddress = contractAddressOrUndefined(sellAsset.assetId);
349
- // Get vault address
350
- const { vault } = await tron.getThorTxData({
351
- sellAsset,
352
- config,
353
- swapperName,
354
- });
355
375
  // Estimate fees using the receive address for accurate energy calculation
356
376
  const tronWeb = new TronWeb({
357
377
  fullHost: deps.config.VITE_TRON_NODE_URL,
378
+ headers: deps.config.VITE_TRON_GRID_API_KEY
379
+ ? { 'TRON-PRO-API-KEY': deps.config.VITE_TRON_GRID_API_KEY }
380
+ : {},
358
381
  });
359
382
  const params = await tronWeb.trx.getChainParameters();
360
383
  const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
@@ -364,7 +387,7 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
364
387
  // TRC20: Estimate energy with actual recipient
365
388
  try {
366
389
  const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
367
- { type: 'address', value: vault }, // Use vault as recipient
390
+ { type: 'address', value: vault },
368
391
  {
369
392
  type: 'uint256',
370
393
  value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
@@ -398,8 +421,13 @@ export const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType
398
421
  // For quotes, fees will be calculated in getTronTransactionFees when executing
399
422
  return Promise.resolve(makeThorTradeRateOrQuote({
400
423
  route,
401
- allowanceContract: '0x0', // not applicable to TRON
424
+ allowanceContract: '0x0',
402
425
  memo,
426
+ thorchainTransactionMetadata: {
427
+ to: vault,
428
+ memo,
429
+ value: sellAmountCryptoBaseUnit,
430
+ },
403
431
  feeData: {
404
432
  networkFeeCryptoBaseUnit,
405
433
  protocolFees: getProtocolFees(route.quote),