@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
@@ -4,19 +4,10 @@ import { Err, Ok } from '@sniptt/monads';
4
4
  import qs from 'qs';
5
5
  import { TradeQuoteError } from '../types.js';
6
6
  import { createTradeAmountTooSmallErr, makeSwapErrorRight } from '../utils.js';
7
- import { getThresholdedAffiliateBps } from './getThresholdedAffiliateBps/getThresholdedAffiliateBps.js';
8
7
  import { getAffiliate, getDaemonUrl, getNativePrecision, getPoolAssetId } from './index.js';
9
8
  import { thorService } from './service.js';
10
9
  export const getQuote = async (input, deps) => {
11
10
  const { buyAssetId, receiveAddress, sellAsset, sellAmountCryptoBaseUnit, streaming, streamingInterval, affiliateBps, swapperName, } = input;
12
- // don't apply an affiliate fee if it's below the outbound fee for the inbound pool
13
- const thresholdedAffiliateBps = await getThresholdedAffiliateBps({
14
- sellAsset,
15
- sellAmountCryptoBaseUnit,
16
- affiliateBps,
17
- config: deps.config,
18
- swapperName,
19
- });
20
11
  const buyPoolId = getPoolAssetId({ assetId: buyAssetId, swapperName });
21
12
  const sellPoolId = getPoolAssetId({ assetId: sellAsset.assetId, swapperName });
22
13
  const sellAmountCryptoPrecision = BigAmount.fromBaseUnit({
@@ -37,33 +28,40 @@ export const getQuote = async (input, deps) => {
37
28
  from_asset: sellPoolId,
38
29
  to_asset: buyPoolId,
39
30
  destination: parsedReceiveAddress,
40
- affiliate_bps: thresholdedAffiliateBps,
31
+ affiliate_bps: affiliateBps,
41
32
  affiliate: getAffiliate(swapperName),
42
33
  ...(streaming && { streaming_interval: streamingInterval }),
43
34
  });
44
35
  const daemonUrl = getDaemonUrl(deps.config, swapperName);
45
36
  const res = await thorService.get(`${daemonUrl}/quote/swap?${queryString}`);
46
- if (res.isErr())
47
- return Err(res.unwrapErr());
48
- const { data } = res.unwrap();
49
- const isError = 'error' in data;
50
- const notEnoughFeeError = isError && /not enough fee/i.test(data.error);
51
- const notEnoughToPayTxFeeError = isError && /not enough to pay transaction fee/i.test(data.error);
52
- const tradingIsHaltedError = isError && /trading is halted/.test(data.error);
53
- if (notEnoughFeeError || notEnoughToPayTxFeeError)
54
- return Err(createTradeAmountTooSmallErr());
55
- if (tradingIsHaltedError) {
56
- return Err(makeSwapErrorRight({
57
- message: `[getQuote]: Trading is halted, cannot process swap`,
58
- code: TradeQuoteError.TradingHalted,
59
- details: { sellAssetId: sellAsset.assetId, buyAssetId },
60
- }));
61
- }
62
- if (isError) {
37
+ // Thornode returns errors as `{ error: string }` in both the 2xx body and the 4xx body.
38
+ // On 4xx axios rejects, so the body lands on `cause.response.data` instead of in the success data.
39
+ const errorMessage = (() => {
40
+ if (res.isErr()) {
41
+ const cause = res.unwrapErr().cause;
42
+ return cause?.response?.data?.error;
43
+ }
44
+ const { data } = res.unwrap();
45
+ return 'error' in data ? data.error : undefined;
46
+ })();
47
+ if (errorMessage) {
48
+ if (/not enough fee/i.test(errorMessage) ||
49
+ /not enough to pay transaction fee/i.test(errorMessage)) {
50
+ return Err(createTradeAmountTooSmallErr());
51
+ }
52
+ if (/trading is halted/i.test(errorMessage)) {
53
+ return Err(makeSwapErrorRight({
54
+ message: `[getQuote]: Trading is halted, cannot process swap`,
55
+ code: TradeQuoteError.TradingHalted,
56
+ details: { sellAssetId: sellAsset.assetId, buyAssetId },
57
+ }));
58
+ }
63
59
  return Err(makeSwapErrorRight({
64
- message: data.error,
60
+ message: errorMessage,
65
61
  code: TradeQuoteError.UnknownError,
66
62
  }));
67
63
  }
68
- return Ok(data);
64
+ if (res.isErr())
65
+ return Err(res.unwrapErr());
66
+ return Ok(res.unwrap().data);
69
67
  };
@@ -23,6 +23,7 @@ export declare const getDaemonUrl: (config: SwapperConfig, swapperName: SwapperN
23
23
  export declare const getMidgardUrl: (config: SwapperConfig, swapperName: SwapperName) => string;
24
24
  export declare const isNativeAsset: (assetId: AssetId, swapperName: SwapperName) => boolean;
25
25
  export declare const getNativePrecision: (assetId: AssetId, swapperName: SwapperName) => 8 | 10;
26
+ export declare const getSwapperNativeAssetId: (swapperName: SwapperName) => AssetId;
26
27
  export declare const getNativeFee: (swapperName: SwapperName) => "2000000" | "2000000000";
27
28
  export declare const getAffiliate: (swapperName: SwapperName) => "ss" | "ssmaya";
28
29
  export declare const getPoolAssetId: ({ assetId, swapperName, }: {
@@ -1,4 +1,4 @@
1
- import { mayachainAssetId, mayachainChainId, thorchainChainId } from '@shapeshiftoss/caip';
1
+ import { mayachainAssetId, mayachainChainId, thorchainAssetId, thorchainChainId, } from '@shapeshiftoss/caip';
2
2
  import * as adapters from '@shapeshiftoss/chain-adapters';
3
3
  import { assetIdToMayaPoolAssetId, CACAO_PRECISION, isCacao, MAYACHAIN_AFFILIATE_NAME, MAYACHAIN_PRECISION, MAYACHAIN_STREAM_SWAP_SOURCE, } from '../swappers/MayachainSwapper/index.js';
4
4
  import { assetIdToThorPoolAssetId, isRune, THORCHAIN_AFFILIATE_NAME, THORCHAIN_LONGTAIL_STREAMING_SWAP_SOURCE, THORCHAIN_LONGTAIL_SWAP_SOURCE, THORCHAIN_PRECISION, THORCHAIN_STREAM_SWAP_SOURCE, } from '../swappers/ThorchainSwapper/index.js';
@@ -69,6 +69,16 @@ export const getNativePrecision = (assetId, swapperName) => {
69
69
  throw new Error(`Invalid swapper: ${swapperName}`);
70
70
  }
71
71
  };
72
+ export const getSwapperNativeAssetId = (swapperName) => {
73
+ switch (swapperName) {
74
+ case SwapperName.Thorchain:
75
+ return thorchainAssetId;
76
+ case SwapperName.Mayachain:
77
+ return mayachainAssetId;
78
+ default:
79
+ throw new Error(`Invalid swapper: ${swapperName}`);
80
+ }
81
+ };
72
82
  export const getNativeFee = (swapperName) => {
73
83
  switch (swapperName) {
74
84
  case SwapperName.Thorchain:
@@ -1,2 +1,2 @@
1
1
  import type { ThorNodeTxSchema } from './types.js';
2
- export declare const parseThorBuyTxHash: (sellTxId: string, latestOutTx: ThorNodeTxSchema | undefined, nativeChain: "THOR" | "MAYA") => string | undefined;
2
+ export declare const parseThorBuyTxHash: (sellTxId: string, latestOutTx: ThorNodeTxSchema | undefined, nativeChain: 'THOR' | 'MAYA') => string | undefined;
@@ -1,5 +1,5 @@
1
1
  export declare const thorService: {
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,9 +2,9 @@ import { bnOrZero, contractAddressOrUndefined } from '@shapeshiftoss/utils';
2
2
  import { TronWeb } from 'tronweb';
3
3
  import { getExecutableTradeStep, isExecutableTradeQuote } from '../../utils.js';
4
4
  import { getThorTxData } from './getThorTxData.js';
5
- const getChainPrices = async (rpcUrl) => {
5
+ const getChainPrices = async (rpcUrl, headers) => {
6
6
  try {
7
- const tronWeb = new TronWeb({ fullHost: rpcUrl });
7
+ const tronWeb = new TronWeb({ fullHost: rpcUrl, headers });
8
8
  const params = await tronWeb.trx.getChainParameters();
9
9
  const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
10
10
  const energyPrice = params.find(p => p.key === 'getEnergyFee')?.value ?? 420;
@@ -26,11 +26,14 @@ export const getTronTransactionFees = async (args, swapperName) => {
26
26
  const { vault } = await getThorTxData({ sellAsset, config, swapperName });
27
27
  const contractAddress = contractAddressOrUndefined(sellAsset.assetId);
28
28
  const rpcUrl = config.VITE_TRON_NODE_URL;
29
+ const tronGridHeaders = config.VITE_TRON_GRID_API_KEY
30
+ ? { 'TRON-PRO-API-KEY': config.VITE_TRON_GRID_API_KEY }
31
+ : {};
29
32
  try {
30
- const tronWeb = new TronWeb({ fullHost: rpcUrl });
33
+ const tronWeb = new TronWeb({ fullHost: rpcUrl, headers: tronGridHeaders });
31
34
  if (contractAddress) {
32
35
  // TRC20 transfer - estimate energy cost
33
- const { energyPrice } = await getChainPrices(rpcUrl);
36
+ const { energyPrice } = await getChainPrices(rpcUrl, tronGridHeaders);
34
37
  const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
35
38
  { type: 'address', value: vault },
36
39
  { type: 'uint256', value: sellAmountIncludingProtocolFeesCryptoBaseUnit },
@@ -41,7 +44,7 @@ export const getTronTransactionFees = async (args, swapperName) => {
41
44
  }
42
45
  else {
43
46
  // TRX transfer with memo - build transaction to get accurate size
44
- const { bandwidthPrice } = await getChainPrices(rpcUrl);
47
+ const { bandwidthPrice } = await getChainPrices(rpcUrl, tronGridHeaders);
45
48
  let tx = await tronWeb.transactionBuilder.sendTrx(vault, bnOrZero(sellAmountIncludingProtocolFeesCryptoBaseUnit).toNumber(), from);
46
49
  // Add memo to get accurate size with memo overhead
47
50
  const txWithMemo = await tronWeb.transactionBuilder.addUpdateData(tx, memo, 'utf8');
@@ -71,7 +71,7 @@ export type ThornodeQuoteResponseSuccess = {
71
71
  total_swap_seconds?: number;
72
72
  warning: string;
73
73
  };
74
- type ThornodeResponseError = {
74
+ export type ThornodeResponseError = {
75
75
  error: string;
76
76
  };
77
77
  export type ThornodeQuoteResponse = ThornodeQuoteResponseSuccess | ThornodeResponseError;
@@ -1,2 +1,2 @@
1
1
  import type { GetUnsignedTronTransactionArgs } from '../types.js';
2
- export declare const getTronTransactionFees: ({ tradeQuote, stepIndex, }: Pick<GetUnsignedTronTransactionArgs, "tradeQuote" | "stepIndex">) => Promise<string>;
2
+ export declare const getTronTransactionFees: ({ tradeQuote, stepIndex, }: Pick<GetUnsignedTronTransactionArgs, 'tradeQuote' | 'stepIndex'>) => Promise<string>;
@@ -11,6 +11,7 @@ import type Polyglot from 'node-polyglot';
11
11
  import type { InterpolationOptions } from 'node-polyglot';
12
12
  import type { Address, Hex } from 'viem';
13
13
  import type { AcrossTransactionMetadata } from './swappers/AcrossSwapper/utils/types.js';
14
+ import type { BobGatewayMetadata } from './swappers/BobGatewaySwapper/types.js';
14
15
  import type { CowMessageToSign } from './swappers/CowSwapper/types.js';
15
16
  import type { DebridgeTransactionMetadata } from './swappers/DebridgeSwapper/utils/types.js';
16
17
  import type { RelayTransactionMetadata } from './swappers/RelaySwapper/utils/types.js';
@@ -22,6 +23,7 @@ export type SwapperConfig = {
22
23
  VITE_THORCHAIN_NODE_URL: string;
23
24
  VITE_MAYACHAIN_NODE_URL: string;
24
25
  VITE_TRON_NODE_URL: string;
26
+ VITE_TRON_GRID_API_KEY: string;
25
27
  VITE_FEATURE_THORCHAINSWAP_LONGTAIL: boolean;
26
28
  VITE_FEATURE_THORCHAINSWAP_L1_TO_LONGTAIL: boolean;
27
29
  VITE_THORCHAIN_MIDGARD_URL: string;
@@ -50,6 +52,7 @@ export type SwapperConfig = {
50
52
  VITE_ACROSS_API_URL: string;
51
53
  VITE_ACROSS_INTEGRATOR_ID: string;
52
54
  VITE_DEBRIDGE_API_URL: string;
55
+ VITE_BOB_GATEWAY_API_KEY: string;
53
56
  };
54
57
  export declare enum SwapperName {
55
58
  Thorchain = "THORChain",
@@ -69,7 +72,8 @@ export declare enum SwapperName {
69
72
  Avnu = "AVNU",
70
73
  Stonfi = "STON.fi",
71
74
  Across = "Across",
72
- Debridge = "deBridge"
75
+ Debridge = "deBridge",
76
+ BobGateway = "BOB Gateway"
73
77
  }
74
78
  export type SwapSource = SwapperName | `${SwapperName} • ${string}`;
75
79
  export type SwapErrorRight = {
@@ -95,7 +99,9 @@ export declare enum TradeQuoteError {
95
99
  FinalQuoteMaxSlippageExceeded = "FinalQuoteMaxSlippageExceeded",
96
100
  FinalQuoteExecutionReverted = "FinalQuoteExecutionReverted",
97
101
  Timeout = "Timeout",
98
- UnknownError = "UnknownError"
102
+ UnknownError = "UnknownError",
103
+ InsufficientFunds = "InsufficientFunds",
104
+ InsufficientFundsUnconfirmed = "InsufficientFundsUnconfirmed"
99
105
  }
100
106
  export type UtxoFeeData = {
101
107
  satsPerByte: string;
@@ -133,7 +139,6 @@ type CommonTradeInputBase = {
133
139
  buyAsset: Asset;
134
140
  sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
135
141
  affiliateBps: string;
136
- affiliateAddress?: string;
137
142
  allowMultiHop: boolean;
138
143
  slippageTolerancePercentageDecimal?: string;
139
144
  };
@@ -327,6 +332,12 @@ export type TradeQuoteStep = {
327
332
  thorchainSpecific?: {
328
333
  maxStreamingQuantity?: number;
329
334
  };
335
+ thorchainTransactionMetadata?: {
336
+ to: string;
337
+ data?: string;
338
+ value?: string;
339
+ memo?: string;
340
+ };
330
341
  relayTransactionMetadata?: RelayTransactionMetadata;
331
342
  butterSwapTransactionMetadata?: {
332
343
  to: string;
@@ -396,6 +407,7 @@ export type TradeQuoteStep = {
396
407
  };
397
408
  acrossTransactionMetadata?: AcrossTransactionMetadata;
398
409
  debridgeTransactionMetadata?: DebridgeTransactionMetadata;
410
+ bobSpecific?: BobGatewayMetadata;
399
411
  affiliateFee?: AffiliateFee;
400
412
  };
401
413
  export type TradeRateStep = Omit<TradeQuoteStep, 'accountNumber'> & {
@@ -452,6 +464,7 @@ export type SwapperSpecificMetadata = {
452
464
  relayTransactionMetadata: RelayTransactionMetadata | undefined;
453
465
  acrossTransactionMetadata: AcrossTransactionMetadata | undefined;
454
466
  debridgeTransactionMetadata: DebridgeTransactionMetadata | undefined;
467
+ bobSpecific?: BobGatewayMetadata;
455
468
  relayerExplorerTxLink: string | undefined;
456
469
  relayerTxHash: string | undefined;
457
470
  stepIndex: SupportedTradeQuoteStepIndex;
package/dist/esm/types.js CHANGED
@@ -18,6 +18,7 @@ export var SwapperName;
18
18
  SwapperName["Stonfi"] = "STON.fi";
19
19
  SwapperName["Across"] = "Across";
20
20
  SwapperName["Debridge"] = "deBridge";
21
+ SwapperName["BobGateway"] = "BOB Gateway";
21
22
  })(SwapperName || (SwapperName = {}));
22
23
  export var TradeQuoteError;
23
24
  (function (TradeQuoteError) {
@@ -53,6 +54,10 @@ export var TradeQuoteError;
53
54
  TradeQuoteError["Timeout"] = "Timeout";
54
55
  // catch-all for unknown issues
55
56
  TradeQuoteError["UnknownError"] = "UnknownError";
57
+ // the swapper performed on chain balance checks and determined the user didn't have the funds to perform the swap
58
+ TradeQuoteError["InsufficientFunds"] = "InsufficientFunds";
59
+ // the user's confirmed balance is insufficient — funds may exist but are still confirming on chain (e.g. unconfirmed UTXO deposits)
60
+ TradeQuoteError["InsufficientFundsUnconfirmed"] = "InsufficientFundsUnconfirmed";
56
61
  })(TradeQuoteError || (TradeQuoteError = {}));
57
62
  export var TransactionExecutionState;
58
63
  (function (TransactionExecutionState) {
@@ -23,39 +23,39 @@ export const getAllowanceStorageSlot = (ownerAddress, spenderAddress, allowanceS
23
23
  // USDC (BEP20 - BSC): balance at slot 1, allowance at slot 2
24
24
  export const KNOWN_BALANCE_SLOTS = {
25
25
  // USDT - Native Tether deployment (custom slot 2)
26
- '0xdac17f958d2ee523a2206206994597c13d831ec7': 2, // USDT Ethereum
26
+ '0xdac17f958d2ee523a2206206994597c13d831ec7': 2,
27
27
  // Slot 51 pattern (L2GatewayToken + ERC20Upgradeable + storage gaps)
28
28
  // Various L2 tokens use this pattern with different implementations
29
- '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 51, // USDT Arbitrum (StandardArbERC20)
30
- '0x912ce59144191c1204e64559fe8253a0e49e6548': 51, // ARB Arbitrum (StandardArbERC20)
31
- '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 51, // USDT Avalanche (TransparentProxy)
32
- '0x01bff41798a0bcf287b996046ca68b395dbc1071': 51, // USDT0 Optimism (LayerZero OFT - https://docs.usdt0.to)
29
+ '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 51,
30
+ '0x912ce59144191c1204e64559fe8253a0e49e6548': 51,
31
+ '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 51,
32
+ '0x01bff41798a0bcf287b996046ca68b395dbc1071': 51,
33
33
  // Wormhole bridge pattern (slot 5)
34
- '0xca7dec8550f43a5e46e3dfb95801f64280e75b27': 5, // SWEAT Arbitrum (Wormhole bridge)
34
+ '0xca7dec8550f43a5e46e3dfb95801f64280e75b27': 5,
35
35
  // USDT - BEP20 pattern (slot 1 - Binance-Peg token)
36
- '0x55d398326f99059ff775485246999027b3197955': 1, // USDT BSC (confirmed)
36
+ '0x55d398326f99059ff775485246999027b3197955': 1,
37
37
  // USDT - xDai bridge pattern (slot 3)
38
- '0x4ecaba5870353805a9f068101a40e0f32ed605c6': 3, // USDT Gnosis (confirmed)
38
+ '0x4ecaba5870353805a9f068101a40e0f32ed605c6': 3,
39
39
  // USDT - Standard ERC20 deployments (slot 0)
40
40
  // Polygon confirmed, Optimism bridged USDT (0x94b008aa...) also uses slot 0
41
41
  // USDC (Circle native deployments - all use slot 9)
42
- '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 9, // USDC Ethereum
43
- '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': 9, // USDC Avalanche
44
- '0x0b2c639c533813f4aa9d7837caf62653d097ff85': 9, // USDC Optimism
45
- '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': 9, // USDC Polygon
46
- '0xaf88d065e77c8cc2239327c5edb3a432268e5831': 9, // USDC Arbitrum
47
- '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': 9, // USDC Base
42
+ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 9,
43
+ '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': 9,
44
+ '0x0b2c639c533813f4aa9d7837caf62653d097ff85': 9,
45
+ '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359': 9,
46
+ '0xaf88d065e77c8cc2239327c5edb3a432268e5831': 9,
47
+ '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': 9,
48
48
  // USDC (BEP20 pattern on BSC - slot 1)
49
49
  '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d': 1, // USDC BSC (BEP20)
50
50
  };
51
51
  export const KNOWN_ALLOWANCE_SLOTS = {
52
52
  // USDT allowance slots (explicit mapping for all non-standard implementations)
53
- '0xdac17f958d2ee523a2206206994597c13d831ec7': 5, // USDT Ethereum (native Tether)
54
- '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 52, // USDT Arbitrum (StandardArbERC20)
55
- '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 52, // USDT Avalanche (StandardArbERC20)
56
- '0x01bff41798a0bcf287b996046ca68b395dbc1071': 52, // USDT0 Optimism (LayerZero OFT)
57
- '0x55d398326f99059ff775485246999027b3197955': 2, // USDT BSC (BEP20)
58
- '0x4ecaba5870353805a9f068101a40e0f32ed605c6': 4, // USDT Gnosis (xDai bridge)
53
+ '0xdac17f958d2ee523a2206206994597c13d831ec7': 5,
54
+ '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9': 52,
55
+ '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': 52,
56
+ '0x01bff41798a0bcf287b996046ca68b395dbc1071': 52,
57
+ '0x55d398326f99059ff775485246999027b3197955': 2,
58
+ '0x4ecaba5870353805a9f068101a40e0f32ed605c6': 4,
59
59
  // Note: Polygon and Optimism standard bridged USDT (0x94b008aa...) use slot 1 (fallback)
60
60
  // Note: SWEAT (slot 5) allowance auto-inferred to slot 6 via Wormhole pattern
61
61
  // USDC allowance slots (BSC uses BEP20 pattern, not Circle FiatToken)
@@ -12,7 +12,7 @@ export declare const makeSwapErrorRight: ({ details, cause, code, message, }: {
12
12
  message: string;
13
13
  details?: unknown;
14
14
  cause?: unknown;
15
- code?: TradeQuoteError;
15
+ code?: TradeQuoteError | undefined;
16
16
  }) => SwapErrorRight;
17
17
  export declare const createTradeAmountTooSmallErr: (details?: {
18
18
  minAmountCryptoBaseUnit: string;
@@ -21,9 +21,9 @@ export declare const createTradeAmountTooSmallErr: (details?: {
21
21
  export declare const createCache: (maxAge: number, cachedUrls: string[], axiosConfig: AxiosRequestConfig) => AxiosInstance;
22
22
  export declare const AsyncResultOf: <T>(promise: Promise<T>) => Promise<Result<T, Error>>;
23
23
  export declare const makeSwapperAxiosServiceMonadic: (service: AxiosInstance) => {
24
- get: <T = any>(url: string, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T>, SwapErrorRight>>;
25
- post: <T = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T>, SwapErrorRight>>;
26
- delete: <T = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T>, SwapErrorRight>>;
24
+ get: <T = any>(url: string, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T, any, {}>, SwapErrorRight>>;
25
+ post: <T_1 = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T_1, any, {}>, SwapErrorRight>>;
26
+ delete: <T_2 = any>(url: string, data: any, config?: AxiosRequestConfig<any>) => Promise<Result<AxiosResponse<T_2, any, {}>, SwapErrorRight>>;
27
27
  };
28
28
  export declare const getHopByIndex: (quote: TradeQuote | TradeRate | undefined, index: SupportedTradeQuoteStepIndex) => TradeQuoteStep | undefined;
29
29
  export declare const executeEvmTransaction: (txToSign: SignTx<EvmChainId>, callbacks: EvmTransactionExecutionProps) => Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "17.7.2",
3
+ "version": "17.8.0",
4
4
  "repository": "https://github.com/shapeshift/web",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  "@coral-xyz/anchor": "0.29.0",
29
29
  "@cowprotocol/app-data": "^2.3.0",
30
30
  "@defuse-protocol/one-click-sdk-typescript": "^0.1.1-0.2",
31
+ "@gobob/bob-sdk": "5.6.0",
31
32
  "@mysten/sui": "^1.45.2",
32
33
  "@shapeshiftoss/bitcoinjs-lib": "7.0.0-shapeshift.0",
33
34
  "@sniptt/monads": "^0.5.10",
@@ -49,13 +50,13 @@
49
50
  "retry-axios": "^2.6.0",
50
51
  "uuid": "^9.0.0",
51
52
  "viem": "2.43.5",
52
- "@shapeshiftoss/caip": "^8.16.7",
53
- "@shapeshiftoss/chain-adapters": "^11.3.9",
54
- "@shapeshiftoss/types": "^8.6.7",
53
+ "@shapeshiftoss/caip": "^8.16.9",
54
+ "@shapeshiftoss/chain-adapters": "^11.4.0",
55
+ "@shapeshiftoss/contracts": "^1.0.7",
55
56
  "@shapeshiftoss/hdwallet-core": "^1.62.41",
56
- "@shapeshiftoss/contracts": "^1.0.5-coderabbit-fix.2",
57
- "@shapeshiftoss/unchained-client": "^10.14.10",
58
- "@shapeshiftoss/utils": "^1.0.5"
57
+ "@shapeshiftoss/types": "^8.6.8",
58
+ "@shapeshiftoss/utils": "^1.1.0",
59
+ "@shapeshiftoss/unchained-client": "^10.14.11"
59
60
  },
60
61
  "devDependencies": {
61
62
  "@types/lodash": "^4.14.178",
@@ -1,11 +0,0 @@
1
- import type { SunioRoute } from '../types';
2
- export type BuildSwapTransactionArgs = {
3
- route: SunioRoute;
4
- from: string;
5
- to: string;
6
- sellAmountCryptoBaseUnit: string;
7
- minBuyAmountCryptoBaseUnit: string;
8
- rpcUrl: string;
9
- deadline?: number;
10
- };
11
- export declare const buildSunioSwapTransaction: (args: BuildSwapTransactionArgs) => Promise<any>;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSunioSwapTransaction = void 0;
4
- const tronweb_1 = require("tronweb");
5
- const constants_1 = require("./constants");
6
- const convertAddressesToEvmFormat = (value) => {
7
- if (Array.isArray(value)) {
8
- return value.map(v => convertAddressesToEvmFormat(v));
9
- }
10
- if (typeof value === 'string' && value.startsWith('T') && tronweb_1.TronWeb.isAddress(value)) {
11
- const hex = tronweb_1.TronWeb.address.toHex(value);
12
- return hex.replace(/^41/, '0x');
13
- }
14
- return value;
15
- };
16
- const buildSunioSwapTransaction = async (args) => {
17
- const { route, from, to, sellAmountCryptoBaseUnit, minBuyAmountCryptoBaseUnit, rpcUrl, deadline, } = args;
18
- const tronWeb = new tronweb_1.TronWeb({
19
- fullHost: rpcUrl,
20
- });
21
- const path = route.tokens;
22
- const poolVersion = route.poolVersions;
23
- const versionLen = Array(poolVersion.length).fill(2);
24
- const fees = route.poolFees.map(fee => Number(fee));
25
- const swapData = {
26
- amountIn: sellAmountCryptoBaseUnit,
27
- amountOutMin: minBuyAmountCryptoBaseUnit,
28
- recipient: to,
29
- deadline: deadline ?? Math.floor(Date.now() / 1000) + 60 * 20,
30
- };
31
- const parameters = [
32
- { type: 'address[]', value: path },
33
- { type: 'string[]', value: poolVersion },
34
- { type: 'uint256[]', value: versionLen },
35
- { type: 'uint24[]', value: fees },
36
- {
37
- type: 'tuple(uint256,uint256,address,uint256)',
38
- value: convertAddressesToEvmFormat([
39
- swapData.amountIn,
40
- swapData.amountOutMin,
41
- swapData.recipient,
42
- swapData.deadline,
43
- ]),
44
- },
45
- ];
46
- const functionSelector = 'swapExactInput(address[],string[],uint256[],uint24[],(uint256,uint256,address,uint256))';
47
- const options = {
48
- feeLimit: 100_000_000,
49
- callValue: 0,
50
- };
51
- const txData = await tronWeb.transactionBuilder.triggerSmartContract(constants_1.SUNIO_SMART_ROUTER_CONTRACT, functionSelector, options, parameters, from);
52
- if (!txData.result || !txData.result.result) {
53
- throw new Error('[Sun.io] Failed to build swap transaction');
54
- }
55
- return txData.transaction;
56
- };
57
- exports.buildSunioSwapTransaction = buildSunioSwapTransaction;
@@ -1,11 +0,0 @@
1
- import type { Asset } from '@shapeshiftoss/types';
2
- import type { SwapperConfig, SwapperName } from '../../types';
3
- export declare const getOutboundFeeInSellAssetThorBaseUnit: (runePerAsset: string, swapperName: SwapperName) => BigNumber;
4
- export declare const getExpectedAffiliateFeeSellAssetThorUnit: (sellAmountCryptoBaseUnit: string, sellAsset: Asset, affiliateBps: string, swapperName: SwapperName) => BigNumber;
5
- export declare const getThresholdedAffiliateBps: ({ sellAsset, affiliateBps, sellAmountCryptoBaseUnit, config, swapperName, }: {
6
- sellAsset: Asset;
7
- affiliateBps: string;
8
- sellAmountCryptoBaseUnit: string;
9
- config: SwapperConfig;
10
- swapperName: SwapperName;
11
- }) => Promise<string>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getThresholdedAffiliateBps = exports.getExpectedAffiliateFeeSellAssetThorUnit = exports.getOutboundFeeInSellAssetThorBaseUnit = void 0;
4
- const utils_1 = require("@shapeshiftoss/utils");
5
- const index_1 = require("../index");
6
- const getOutboundFeeInSellAssetThorBaseUnit = (runePerAsset, swapperName) => {
7
- return (0, utils_1.bn)((0, index_1.getNativeFee)(swapperName)).dividedBy(runePerAsset);
8
- };
9
- exports.getOutboundFeeInSellAssetThorBaseUnit = getOutboundFeeInSellAssetThorBaseUnit;
10
- const getExpectedAffiliateFeeSellAssetThorUnit = (sellAmountCryptoBaseUnit, sellAsset, affiliateBps, swapperName) => {
11
- const sellAmountThorUnit = (0, utils_1.convertPrecision)({
12
- value: sellAmountCryptoBaseUnit,
13
- inputExponent: sellAsset.precision,
14
- outputExponent: (0, index_1.getNativePrecision)(sellAsset.assetId, swapperName),
15
- });
16
- const affiliatePercent = (0, utils_1.convertBasisPointsToDecimalPercentage)(affiliateBps);
17
- return sellAmountThorUnit.times(affiliatePercent);
18
- };
19
- exports.getExpectedAffiliateFeeSellAssetThorUnit = getExpectedAffiliateFeeSellAssetThorUnit;
20
- // don't apply an affiliate fee if it's below the outbound fee for the inbound pool
21
- const getThresholdedAffiliateBps = async ({ sellAsset, affiliateBps, sellAmountCryptoBaseUnit, config, swapperName, }) => {
22
- const midgardUrl = (0, index_1.getMidgardUrl)(config, swapperName);
23
- const outboundFeeSellAssetThorUnit = await (async () => {
24
- if ((0, index_1.isNativeAsset)(sellAsset.assetId, swapperName))
25
- return (0, index_1.getNativeFee)(swapperName);
26
- const sellPoolId = (0, index_1.getPoolAssetId)({ assetId: sellAsset.assetId, swapperName });
27
- // get pool data for the sell asset
28
- const res = await index_1.thorService.get(`${midgardUrl}/pool/${sellPoolId}`);
29
- if (res.isErr())
30
- throw res.unwrapErr();
31
- const pool = res.unwrap().data;
32
- // calculate the rune outbound fee denominated in the sell asset, in native units
33
- return (0, exports.getOutboundFeeInSellAssetThorBaseUnit)(pool.assetPrice, swapperName);
34
- })();
35
- // calculate the expected affiliate fee, in native units
36
- const expectedAffiliateFeeSellAssetThorUnit = (0, exports.getExpectedAffiliateFeeSellAssetThorUnit)(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, swapperName);
37
- const isAffiliateFeeBelowOutboundFee = expectedAffiliateFeeSellAssetThorUnit.lte(outboundFeeSellAssetThorUnit);
38
- return isAffiliateFeeBelowOutboundFee ? '0' : affiliateBps;
39
- };
40
- exports.getThresholdedAffiliateBps = getThresholdedAffiliateBps;
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
4
- const utils_1 = require("@shapeshiftoss/utils");
5
- const monads_1 = require("@sniptt/monads");
6
- const vitest_1 = require("vitest");
7
- const test_data_1 = require("../../swappers/utils/test-data");
8
- const types_1 = require("../../types");
9
- const service_1 = require("../service");
10
- const getThresholdedAffiliateBps_1 = require("./getThresholdedAffiliateBps");
11
- const mockedThorService = vitest_1.vi.mocked(service_1.thorService);
12
- const mocks = vitest_1.vi.hoisted(() => ({
13
- get: vitest_1.vi.fn(),
14
- post: vitest_1.vi.fn(),
15
- }));
16
- vitest_1.vi.mock('../service', () => {
17
- const mockAxios = {
18
- default: {
19
- create: vitest_1.vi.fn(() => ({
20
- get: mocks.get,
21
- post: mocks.post,
22
- })),
23
- },
24
- };
25
- return {
26
- thorService: mockAxios.default.create(),
27
- };
28
- });
29
- (0, vitest_1.describe)('getOutboundFeeInSellAssetThorBaseUnit', () => {
30
- (0, vitest_1.it)('should return 0.02 rune denominated in the target asset, in thor units', () => {
31
- const assetPricePrecision = '4.00000'; // 1 token is 4x as valuable as 1 rune
32
- (0, vitest_1.expect)((0, getThresholdedAffiliateBps_1.getOutboundFeeInSellAssetThorBaseUnit)(assetPricePrecision, types_1.SwapperName.Thorchain).toNumber()).toEqual(Number(chain_adapters_1.thorchain.NATIVE_FEE) / 4);
33
- });
34
- });
35
- (0, vitest_1.describe)('getExpectedAffiliateFeeSellAssetThorUnit', () => {
36
- (0, vitest_1.it)('should return the correct affiliate fee in thor base units', () => {
37
- const sellAmountCryptoBaseUnit = '1000000000000000000'; // 1 eth
38
- const affiliateBps = '35';
39
- const sellAsset = test_data_1.ETH;
40
- const result = (0, getThresholdedAffiliateBps_1.getExpectedAffiliateFeeSellAssetThorUnit)(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, types_1.SwapperName.Thorchain);
41
- const expectation = (0, utils_1.bn)('100000000').times('0.0035').toFixed(0);
42
- (0, vitest_1.expect)(result.toFixed(0)).toEqual(expectation);
43
- });
44
- (0, vitest_1.it)('returns 0 when affiliateBps is 0', () => {
45
- const sellAmountCryptoBaseUnit = '1000000000000000000'; // 1 eth
46
- const affiliateBps = '0';
47
- const sellAsset = test_data_1.ETH;
48
- const result = (0, getThresholdedAffiliateBps_1.getExpectedAffiliateFeeSellAssetThorUnit)(sellAmountCryptoBaseUnit, sellAsset, affiliateBps, types_1.SwapperName.Thorchain);
49
- const expectation = '0';
50
- (0, vitest_1.expect)(result.toFixed(0)).toEqual(expectation);
51
- });
52
- });
53
- (0, vitest_1.describe)('getThresholdedAffiliateBps', () => {
54
- mockedThorService.get.mockImplementation(() => {
55
- return Promise.resolve((0, monads_1.Ok)({
56
- data: {
57
- assetPrice: '100', // 1 eth = 100 rune
58
- },
59
- }));
60
- });
61
- // outbound fee threshold is 0.02 rune.
62
- // assuming eth price at 100 rune:
63
- // 0.02 rune = 0.02 / 100 = 0.0002 eth
64
- // give an affiliate bps of 50 (0.5%):
65
- // min input amount = threshold eth / affiliate percentage = 0.0002 eth / 0.5% = 0.04 eth
66
- (0, vitest_1.it)('should return 0 when the sell amount is less than or equal to the rune outbound fee', async () => {
67
- const sellAmountCryptoBaseUnit = '40000000000000000'; // 0.04 eth
68
- const affiliateBps = '50'; // 0.5%
69
- const sellAsset = test_data_1.ETH;
70
- const result = await (0, getThresholdedAffiliateBps_1.getThresholdedAffiliateBps)({
71
- sellAsset,
72
- affiliateBps,
73
- sellAmountCryptoBaseUnit,
74
- config: {},
75
- swapperName: types_1.SwapperName.Thorchain,
76
- });
77
- const expectation = '0';
78
- (0, vitest_1.expect)(result).toEqual(expectation);
79
- });
80
- (0, vitest_1.it)('should return input affiliate bps when the sell amount is greater than the rune outbound fee', async () => {
81
- const sellAmountCryptoBaseUnit = '40000000000000001'; // > 0.04 eth
82
- const affiliateBps = '50'; // 0.5%
83
- const sellAsset = test_data_1.ETH;
84
- const result = await (0, getThresholdedAffiliateBps_1.getThresholdedAffiliateBps)({
85
- sellAsset,
86
- affiliateBps,
87
- sellAmountCryptoBaseUnit,
88
- config: {},
89
- swapperName: types_1.SwapperName.Thorchain,
90
- });
91
- const expectation = affiliateBps;
92
- (0, vitest_1.expect)(result).toEqual(expectation);
93
- });
94
- });
@@ -1,11 +0,0 @@
1
- import type { SunioRoute } from '../types.js';
2
- export type BuildSwapTransactionArgs = {
3
- route: SunioRoute;
4
- from: string;
5
- to: string;
6
- sellAmountCryptoBaseUnit: string;
7
- minBuyAmountCryptoBaseUnit: string;
8
- rpcUrl: string;
9
- deadline?: number;
10
- };
11
- export declare const buildSunioSwapTransaction: (args: BuildSwapTransactionArgs) => Promise<any>;