@shapeshiftoss/swapper 17.6.7 → 17.6.8

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 (219) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/constants.js +42 -24
  3. package/dist/cjs/cowswap-utils/constants.js +1 -0
  4. package/dist/cjs/cowswap-utils/index.js +2 -0
  5. package/dist/cjs/index.d.ts +2 -0
  6. package/dist/cjs/index.js +2 -0
  7. package/dist/cjs/swappers/AvnuSwapper/AvnuSwapper.d.ts +2 -0
  8. package/dist/cjs/swappers/AvnuSwapper/AvnuSwapper.js +7 -0
  9. package/dist/cjs/swappers/AvnuSwapper/endpoints.d.ts +2 -0
  10. package/dist/cjs/swappers/AvnuSwapper/endpoints.js +181 -0
  11. package/dist/cjs/swappers/AvnuSwapper/index.d.ts +1 -0
  12. package/dist/cjs/swappers/AvnuSwapper/index.js +5 -0
  13. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.d.ts +3 -0
  14. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +142 -0
  15. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.d.ts +3 -0
  16. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.js +120 -0
  17. package/dist/cjs/swappers/AvnuSwapper/types.d.ts +2 -0
  18. package/dist/cjs/swappers/AvnuSwapper/types.js +2 -0
  19. package/dist/cjs/swappers/AvnuSwapper/utils/constants.d.ts +5 -0
  20. package/dist/cjs/swappers/AvnuSwapper/utils/constants.js +11 -0
  21. package/dist/cjs/swappers/AvnuSwapper/utils/helpers.d.ts +7 -0
  22. package/dist/cjs/swappers/AvnuSwapper/utils/helpers.js +21 -0
  23. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +2 -0
  24. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.test.js +4 -0
  25. package/dist/cjs/swappers/ButterSwap/utils/helpers.js +1 -0
  26. package/dist/cjs/swappers/CetusSwapper/endpoints.js +33 -27
  27. package/dist/cjs/swappers/CetusSwapper/swapperApi/getCetusTradeData.d.ts +24 -0
  28. package/dist/cjs/swappers/CetusSwapper/swapperApi/getCetusTradeData.js +79 -0
  29. package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +44 -69
  30. package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +49 -65
  31. package/dist/cjs/swappers/CetusSwapper/utils/constants.d.ts +1 -0
  32. package/dist/cjs/swappers/CetusSwapper/utils/constants.js +2 -1
  33. package/dist/cjs/swappers/CetusSwapper/utils/helpers.d.ts +6 -11
  34. package/dist/cjs/swappers/CetusSwapper/utils/helpers.js +41 -96
  35. package/dist/cjs/swappers/JupiterSwapper/utils/helpers.d.ts +0 -2
  36. package/dist/cjs/swappers/MayachainSwapper/generated/generatedTradableAssetMap.json +1 -0
  37. package/dist/cjs/swappers/NearIntentsSwapper/NearIntentsSwapper.js +2 -0
  38. package/dist/cjs/swappers/NearIntentsSwapper/endpoints.js +68 -0
  39. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +30 -0
  40. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +53 -5
  41. package/dist/cjs/swappers/NearIntentsSwapper/types.d.ts +1 -1
  42. package/dist/cjs/swappers/NearIntentsSwapper/types.js +8 -0
  43. package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +28 -8
  44. package/dist/cjs/swappers/PortalsSwapper/constants.js +1 -1
  45. package/dist/cjs/swappers/PortalsSwapper/endpoints.js +92 -1
  46. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +29 -17
  47. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +21 -17
  48. package/dist/cjs/swappers/PortalsSwapper/types.js +1 -0
  49. package/dist/cjs/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.d.ts +9 -0
  50. package/dist/cjs/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.js +52 -0
  51. package/dist/cjs/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.d.ts +1 -0
  52. package/dist/cjs/swappers/PortalsSwapper/utils/fetchSquidStatus.d.ts +9 -0
  53. package/dist/cjs/swappers/PortalsSwapper/utils/fetchSquidStatus.js +57 -0
  54. package/dist/cjs/swappers/RelaySwapper/constant.js +3 -0
  55. package/dist/cjs/swappers/RelaySwapper/utils/fetchRelayTrade.js +1 -1
  56. package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +16 -1
  57. package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +20 -0
  58. package/dist/cjs/swappers/RelaySwapper/utils/types.d.ts +13 -4
  59. package/dist/cjs/swappers/RelaySwapper/utils/types.js +5 -1
  60. package/dist/cjs/swappers/SunioSwapper/SunioSwapper.d.ts +2 -0
  61. package/dist/cjs/swappers/SunioSwapper/SunioSwapper.js +7 -0
  62. package/dist/cjs/swappers/SunioSwapper/endpoints.d.ts +2 -0
  63. package/dist/cjs/swappers/SunioSwapper/endpoints.js +131 -0
  64. package/dist/cjs/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.d.ts +3 -0
  65. package/dist/cjs/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.js +8 -0
  66. package/dist/cjs/swappers/SunioSwapper/getSunioTradeRate/getSunioTradeRate.d.ts +3 -0
  67. package/dist/cjs/swappers/SunioSwapper/getSunioTradeRate/getSunioTradeRate.js +8 -0
  68. package/dist/cjs/swappers/SunioSwapper/index.d.ts +4 -0
  69. package/dist/cjs/swappers/SunioSwapper/index.js +23 -0
  70. package/dist/cjs/swappers/SunioSwapper/types.d.ts +22 -0
  71. package/dist/cjs/swappers/SunioSwapper/types.js +12 -0
  72. package/dist/cjs/swappers/SunioSwapper/utils/abi.d.ts +48 -0
  73. package/dist/cjs/swappers/SunioSwapper/utils/abi.js +28 -0
  74. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.d.ts +14 -0
  75. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +32 -0
  76. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +11 -0
  77. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.js +57 -0
  78. package/dist/cjs/swappers/SunioSwapper/utils/constants.d.ts +6 -0
  79. package/dist/cjs/swappers/SunioSwapper/utils/constants.js +16 -0
  80. package/dist/cjs/swappers/SunioSwapper/utils/fetchFromSunio.d.ts +11 -0
  81. package/dist/cjs/swappers/SunioSwapper/utils/fetchFromSunio.js +45 -0
  82. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.d.ts +4 -0
  83. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +203 -0
  84. package/dist/cjs/swappers/SunioSwapper/utils/helpers/helpers.d.ts +4 -0
  85. package/dist/cjs/swappers/SunioSwapper/utils/helpers/helpers.js +22 -0
  86. package/dist/cjs/swappers/SunioSwapper/utils/sunioService.d.ts +6 -0
  87. package/dist/cjs/swappers/SunioSwapper/utils/sunioService.js +18 -0
  88. package/dist/cjs/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
  89. package/dist/cjs/swappers/ThorchainSwapper/endpoints.js +2 -0
  90. package/dist/cjs/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +2 -2
  91. package/dist/cjs/swappers/utils/helpers/helpers.js +7 -0
  92. package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +80 -3
  93. package/dist/cjs/thorchain-utils/index.d.ts +1 -0
  94. package/dist/cjs/thorchain-utils/index.js +2 -1
  95. package/dist/cjs/thorchain-utils/tron/getThorTxData.d.ts +12 -0
  96. package/dist/cjs/thorchain-utils/tron/getThorTxData.js +14 -0
  97. package/dist/cjs/thorchain-utils/tron/getTronTransactionFees.d.ts +2 -0
  98. package/dist/cjs/thorchain-utils/tron/getTronTransactionFees.js +65 -0
  99. package/dist/cjs/thorchain-utils/tron/getUnsignedTronTransaction.d.ts +3 -0
  100. package/dist/cjs/thorchain-utils/tron/getUnsignedTronTransaction.js +35 -0
  101. package/dist/cjs/thorchain-utils/tron/index.d.ts +3 -0
  102. package/dist/cjs/thorchain-utils/tron/index.js +19 -0
  103. package/dist/cjs/types.d.ts +74 -9
  104. package/dist/cjs/types.js +2 -0
  105. package/dist/cjs/utils/tenderly/simulate.d.ts +6 -1
  106. package/dist/cjs/utils/tenderly/simulate.js +22 -2
  107. package/dist/cjs/utils/tenderly/types.d.ts +21 -0
  108. package/dist/cjs/utils.d.ts +9 -3
  109. package/dist/cjs/utils.js +53 -1
  110. package/dist/esm/.tsbuildinfo +1 -1
  111. package/dist/esm/constants.js +18 -0
  112. package/dist/esm/cowswap-utils/constants.js +1 -0
  113. package/dist/esm/cowswap-utils/index.js +2 -0
  114. package/dist/esm/index.d.ts +2 -0
  115. package/dist/esm/index.js +2 -0
  116. package/dist/esm/swappers/AvnuSwapper/AvnuSwapper.d.ts +2 -0
  117. package/dist/esm/swappers/AvnuSwapper/AvnuSwapper.js +4 -0
  118. package/dist/esm/swappers/AvnuSwapper/endpoints.d.ts +2 -0
  119. package/dist/esm/swappers/AvnuSwapper/endpoints.js +178 -0
  120. package/dist/esm/swappers/AvnuSwapper/index.d.ts +1 -0
  121. package/dist/esm/swappers/AvnuSwapper/index.js +1 -0
  122. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.d.ts +3 -0
  123. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +138 -0
  124. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.d.ts +3 -0
  125. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.js +116 -0
  126. package/dist/esm/swappers/AvnuSwapper/types.d.ts +2 -0
  127. package/dist/esm/swappers/AvnuSwapper/types.js +1 -0
  128. package/dist/esm/swappers/AvnuSwapper/utils/constants.d.ts +5 -0
  129. package/dist/esm/swappers/AvnuSwapper/utils/constants.js +7 -0
  130. package/dist/esm/swappers/AvnuSwapper/utils/helpers.d.ts +7 -0
  131. package/dist/esm/swappers/AvnuSwapper/utils/helpers.js +17 -0
  132. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +2 -0
  133. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.test.js +4 -0
  134. package/dist/esm/swappers/ButterSwap/utils/helpers.js +1 -0
  135. package/dist/esm/swappers/CetusSwapper/endpoints.js +28 -22
  136. package/dist/esm/swappers/CetusSwapper/swapperApi/getCetusTradeData.d.ts +24 -0
  137. package/dist/esm/swappers/CetusSwapper/swapperApi/getCetusTradeData.js +75 -0
  138. package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +44 -69
  139. package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +50 -66
  140. package/dist/esm/swappers/CetusSwapper/utils/constants.d.ts +1 -0
  141. package/dist/esm/swappers/CetusSwapper/utils/constants.js +1 -0
  142. package/dist/esm/swappers/CetusSwapper/utils/helpers.d.ts +6 -11
  143. package/dist/esm/swappers/CetusSwapper/utils/helpers.js +37 -67
  144. package/dist/esm/swappers/JupiterSwapper/utils/helpers.d.ts +0 -2
  145. package/dist/esm/swappers/MayachainSwapper/generated/generatedTradableAssetMap.json +1 -0
  146. package/dist/esm/swappers/NearIntentsSwapper/NearIntentsSwapper.js +3 -1
  147. package/dist/esm/swappers/NearIntentsSwapper/endpoints.js +68 -0
  148. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +30 -0
  149. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +54 -6
  150. package/dist/esm/swappers/NearIntentsSwapper/types.d.ts +1 -1
  151. package/dist/esm/swappers/NearIntentsSwapper/types.js +8 -0
  152. package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +29 -9
  153. package/dist/esm/swappers/PortalsSwapper/constants.js +1 -1
  154. package/dist/esm/swappers/PortalsSwapper/endpoints.js +92 -1
  155. package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +30 -18
  156. package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +21 -17
  157. package/dist/esm/swappers/PortalsSwapper/types.js +1 -0
  158. package/dist/esm/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.d.ts +9 -0
  159. package/dist/esm/swappers/PortalsSwapper/utils/fetchAxelarscanStatus.js +47 -0
  160. package/dist/esm/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.d.ts +1 -0
  161. package/dist/esm/swappers/PortalsSwapper/utils/fetchSquidStatus.d.ts +9 -0
  162. package/dist/esm/swappers/PortalsSwapper/utils/fetchSquidStatus.js +52 -0
  163. package/dist/esm/swappers/RelaySwapper/constant.js +5 -2
  164. package/dist/esm/swappers/RelaySwapper/utils/fetchRelayTrade.js +1 -1
  165. package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +18 -3
  166. package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +20 -0
  167. package/dist/esm/swappers/RelaySwapper/utils/types.d.ts +13 -4
  168. package/dist/esm/swappers/RelaySwapper/utils/types.js +3 -0
  169. package/dist/esm/swappers/SunioSwapper/SunioSwapper.d.ts +2 -0
  170. package/dist/esm/swappers/SunioSwapper/SunioSwapper.js +4 -0
  171. package/dist/esm/swappers/SunioSwapper/endpoints.d.ts +2 -0
  172. package/dist/esm/swappers/SunioSwapper/endpoints.js +128 -0
  173. package/dist/esm/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.d.ts +3 -0
  174. package/dist/esm/swappers/SunioSwapper/getSunioTradeQuote/getSunioTradeQuote.js +4 -0
  175. package/dist/esm/swappers/SunioSwapper/getSunioTradeRate/getSunioTradeRate.d.ts +3 -0
  176. package/dist/esm/swappers/SunioSwapper/getSunioTradeRate/getSunioTradeRate.js +4 -0
  177. package/dist/esm/swappers/SunioSwapper/index.d.ts +4 -0
  178. package/dist/esm/swappers/SunioSwapper/index.js +4 -0
  179. package/dist/esm/swappers/SunioSwapper/types.d.ts +22 -0
  180. package/dist/esm/swappers/SunioSwapper/types.js +9 -0
  181. package/dist/esm/swappers/SunioSwapper/utils/abi.d.ts +48 -0
  182. package/dist/esm/swappers/SunioSwapper/utils/abi.js +25 -0
  183. package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.d.ts +14 -0
  184. package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +28 -0
  185. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +11 -0
  186. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.js +53 -0
  187. package/dist/esm/swappers/SunioSwapper/utils/constants.d.ts +6 -0
  188. package/dist/esm/swappers/SunioSwapper/utils/constants.js +13 -0
  189. package/dist/esm/swappers/SunioSwapper/utils/fetchFromSunio.d.ts +11 -0
  190. package/dist/esm/swappers/SunioSwapper/utils/fetchFromSunio.js +41 -0
  191. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.d.ts +4 -0
  192. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +199 -0
  193. package/dist/esm/swappers/SunioSwapper/utils/helpers/helpers.d.ts +4 -0
  194. package/dist/esm/swappers/SunioSwapper/utils/helpers/helpers.js +16 -0
  195. package/dist/esm/swappers/SunioSwapper/utils/sunioService.d.ts +6 -0
  196. package/dist/esm/swappers/SunioSwapper/utils/sunioService.js +14 -0
  197. package/dist/esm/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
  198. package/dist/esm/swappers/ThorchainSwapper/endpoints.js +3 -1
  199. package/dist/esm/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +2 -2
  200. package/dist/esm/swappers/utils/helpers/helpers.js +9 -2
  201. package/dist/esm/thorchain-utils/getL1RateOrQuote.js +81 -4
  202. package/dist/esm/thorchain-utils/index.d.ts +1 -0
  203. package/dist/esm/thorchain-utils/index.js +1 -0
  204. package/dist/esm/thorchain-utils/tron/getThorTxData.d.ts +12 -0
  205. package/dist/esm/thorchain-utils/tron/getThorTxData.js +10 -0
  206. package/dist/esm/thorchain-utils/tron/getTronTransactionFees.d.ts +2 -0
  207. package/dist/esm/thorchain-utils/tron/getTronTransactionFees.js +61 -0
  208. package/dist/esm/thorchain-utils/tron/getUnsignedTronTransaction.d.ts +3 -0
  209. package/dist/esm/thorchain-utils/tron/getUnsignedTronTransaction.js +31 -0
  210. package/dist/esm/thorchain-utils/tron/index.d.ts +3 -0
  211. package/dist/esm/thorchain-utils/tron/index.js +3 -0
  212. package/dist/esm/types.d.ts +74 -9
  213. package/dist/esm/types.js +2 -0
  214. package/dist/esm/utils/tenderly/simulate.d.ts +6 -1
  215. package/dist/esm/utils/tenderly/simulate.js +20 -1
  216. package/dist/esm/utils/tenderly/types.d.ts +21 -0
  217. package/dist/esm/utils.d.ts +9 -3
  218. package/dist/esm/utils.js +50 -1
  219. package/package.json +9 -8
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.sunioSwapper = exports.sunioApi = void 0;
18
+ var endpoints_1 = require("./endpoints");
19
+ Object.defineProperty(exports, "sunioApi", { enumerable: true, get: function () { return endpoints_1.sunioApi; } });
20
+ var SunioSwapper_1 = require("./SunioSwapper");
21
+ Object.defineProperty(exports, "sunioSwapper", { enumerable: true, get: function () { return SunioSwapper_1.sunioSwapper; } });
22
+ __exportStar(require("./types"), exports);
23
+ __exportStar(require("./utils/constants"), exports);
@@ -0,0 +1,22 @@
1
+ import type { tronChainId } from '@shapeshiftoss/caip';
2
+ export type SunioSupportedChainId = typeof tronChainId;
3
+ export type SunioRoute = {
4
+ amountIn: string;
5
+ amountOut: string;
6
+ inUsd: string;
7
+ outUsd: string;
8
+ impact: string;
9
+ fee: string;
10
+ tokens: string[];
11
+ symbols: string[];
12
+ poolFees: string[];
13
+ poolVersions: string[];
14
+ stepAmountsOut: string[];
15
+ };
16
+ export type SunioQuoteResponse = {
17
+ code: number;
18
+ message: string;
19
+ data: SunioRoute[];
20
+ };
21
+ export declare const SUNIO_SUPPORTED_DEX_TYPES: readonly ["SUNSWAP_V1", "SUNSWAP_V2", "SUNSWAP_V3", "PSM", "CURVE", "CURVE_COMBINATION", "WTRX"];
22
+ export type SunioDexType = (typeof SUNIO_SUPPORTED_DEX_TYPES)[number];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUNIO_SUPPORTED_DEX_TYPES = void 0;
4
+ exports.SUNIO_SUPPORTED_DEX_TYPES = [
5
+ 'SUNSWAP_V1',
6
+ 'SUNSWAP_V2',
7
+ 'SUNSWAP_V3',
8
+ 'PSM',
9
+ 'CURVE',
10
+ 'CURVE_COMBINATION',
11
+ 'WTRX',
12
+ ];
@@ -0,0 +1,48 @@
1
+ export declare const SUNSWAP_ROUTER_ABI: readonly [{
2
+ readonly name: "swapExactInput";
3
+ readonly type: "function";
4
+ readonly stateMutability: "payable";
5
+ readonly inputs: readonly [{
6
+ readonly internalType: "address[]";
7
+ readonly name: "path";
8
+ readonly type: "address[]";
9
+ }, {
10
+ readonly internalType: "string[]";
11
+ readonly name: "poolVersion";
12
+ readonly type: "string[]";
13
+ }, {
14
+ readonly internalType: "uint256[]";
15
+ readonly name: "versionLen";
16
+ readonly type: "uint256[]";
17
+ }, {
18
+ readonly internalType: "uint24[]";
19
+ readonly name: "fees";
20
+ readonly type: "uint24[]";
21
+ }, {
22
+ readonly internalType: "struct SwapData";
23
+ readonly name: "data";
24
+ readonly type: "tuple";
25
+ readonly components: readonly [{
26
+ readonly internalType: "uint256";
27
+ readonly name: "amountIn";
28
+ readonly type: "uint256";
29
+ }, {
30
+ readonly internalType: "uint256";
31
+ readonly name: "amountOutMin";
32
+ readonly type: "uint256";
33
+ }, {
34
+ readonly internalType: "address";
35
+ readonly name: "to";
36
+ readonly type: "address";
37
+ }, {
38
+ readonly internalType: "uint256";
39
+ readonly name: "deadline";
40
+ readonly type: "uint256";
41
+ }];
42
+ }];
43
+ readonly outputs: readonly [{
44
+ readonly internalType: "uint256[]";
45
+ readonly name: "amountsOut";
46
+ readonly type: "uint256[]";
47
+ }];
48
+ }];
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUNSWAP_ROUTER_ABI = void 0;
4
+ exports.SUNSWAP_ROUTER_ABI = [
5
+ {
6
+ name: 'swapExactInput',
7
+ type: 'function',
8
+ stateMutability: 'payable',
9
+ inputs: [
10
+ { internalType: 'address[]', name: 'path', type: 'address[]' },
11
+ { internalType: 'string[]', name: 'poolVersion', type: 'string[]' },
12
+ { internalType: 'uint256[]', name: 'versionLen', type: 'uint256[]' },
13
+ { internalType: 'uint24[]', name: 'fees', type: 'uint24[]' },
14
+ {
15
+ internalType: 'struct SwapData',
16
+ name: 'data',
17
+ type: 'tuple',
18
+ components: [
19
+ { internalType: 'uint256', name: 'amountIn', type: 'uint256' },
20
+ { internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
21
+ { internalType: 'address', name: 'to', type: 'address' },
22
+ { internalType: 'uint256', name: 'deadline', type: 'uint256' },
23
+ ],
24
+ },
25
+ ],
26
+ outputs: [{ internalType: 'uint256[]', name: 'amountsOut', type: 'uint256[]' }],
27
+ },
28
+ ];
@@ -0,0 +1,14 @@
1
+ import type { SunioRoute } from '../types';
2
+ export type SwapRouteParameters = {
3
+ path: string[];
4
+ poolVersion: string[];
5
+ versionLen: number[];
6
+ fees: number[];
7
+ swapData: {
8
+ amountIn: string;
9
+ amountOutMin: string;
10
+ recipient: string;
11
+ deadline: number;
12
+ };
13
+ };
14
+ export declare const buildSwapRouteParameters: (route: SunioRoute, sellAmountCryptoBaseUnit: string, minBuyAmountCryptoBaseUnit: string, recipient: string, slippageTolerancePercentageDecimal: string) => SwapRouteParameters;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildSwapRouteParameters = void 0;
4
+ const utils_1 = require("@shapeshiftoss/utils");
5
+ const buildSwapRouteParameters = (route, sellAmountCryptoBaseUnit, minBuyAmountCryptoBaseUnit, recipient, slippageTolerancePercentageDecimal) => {
6
+ const path = route.tokens;
7
+ const poolVersion = route.poolVersions;
8
+ const versionLen = poolVersion.map((_, index) => {
9
+ if (index === poolVersion.length - 1) {
10
+ return path.length - index;
11
+ }
12
+ return 2;
13
+ });
14
+ const fees = route.poolFees.map(fee => Number(fee));
15
+ const amountOutWithSlippage = (0, utils_1.bn)(minBuyAmountCryptoBaseUnit)
16
+ .times((0, utils_1.bn)(1).minus(slippageTolerancePercentageDecimal))
17
+ .toFixed(0);
18
+ const swapData = {
19
+ amountIn: sellAmountCryptoBaseUnit,
20
+ amountOutMin: amountOutWithSlippage,
21
+ recipient,
22
+ deadline: Math.floor(Date.now() / 1000) + 60 * 20,
23
+ };
24
+ return {
25
+ path,
26
+ poolVersion,
27
+ versionLen,
28
+ fees,
29
+ swapData,
30
+ };
31
+ };
32
+ exports.buildSwapRouteParameters = buildSwapRouteParameters;
@@ -0,0 +1,11 @@
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>;
@@ -0,0 +1,57 @@
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;
@@ -0,0 +1,6 @@
1
+ export declare const SUNIO_SUPPORTED_CHAIN_IDS: readonly [import("@shapeshiftoss/caip").ChainId];
2
+ export declare const SUNIO_API_BASE_URL = "https://rot.endjgfsv.link";
3
+ export declare const SUNIO_SMART_ROUTER_CONTRACT: "TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj";
4
+ export declare const DEFAULT_SLIPPAGE_PERCENTAGE = "0.005";
5
+ export declare const SUNIO_DEX_TYPES: "PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3";
6
+ export declare const SUNIO_TRON_NATIVE_ADDRESS: "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUNIO_TRON_NATIVE_ADDRESS = exports.SUNIO_DEX_TYPES = exports.DEFAULT_SLIPPAGE_PERCENTAGE = exports.SUNIO_SMART_ROUTER_CONTRACT = exports.SUNIO_API_BASE_URL = exports.SUNIO_SUPPORTED_CHAIN_IDS = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
5
+ exports.SUNIO_SUPPORTED_CHAIN_IDS = [caip_1.tronChainId];
6
+ // NOTE: This domain looks suspicious, but it's the official Sun.io backend API
7
+ // Verified by inspecting XHR requests from sun.io's own frontend application
8
+ // The sun.io frontend makes requests to this endpoint with origin: https://sun.io
9
+ exports.SUNIO_API_BASE_URL = 'https://rot.endjgfsv.link';
10
+ // Smart Exchange Router - aggregates liquidity across V1, V2, V3, PSM, and SunCurve
11
+ // This is the current mainnet router that sun.io's frontend uses
12
+ exports.SUNIO_SMART_ROUTER_CONTRACT = 'TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj';
13
+ exports.DEFAULT_SLIPPAGE_PERCENTAGE = '0.005';
14
+ exports.SUNIO_DEX_TYPES = 'PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3';
15
+ // Native TRX token address (used when assetId is not a TRC-20 token)
16
+ exports.SUNIO_TRON_NATIVE_ADDRESS = 'T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb';
@@ -0,0 +1,11 @@
1
+ import type { AssetId } from '@shapeshiftoss/caip';
2
+ import type { Result } from '@sniptt/monads';
3
+ import type { SwapErrorRight } from '../../../types';
4
+ import type { SunioQuoteResponse } from '../types';
5
+ import type { SunioService } from './sunioService';
6
+ export type FetchSunioQuoteParams = {
7
+ sellAssetId: AssetId;
8
+ buyAssetId: AssetId;
9
+ sellAmountCryptoBaseUnit: string;
10
+ };
11
+ export declare const fetchSunioQuote: (params: FetchSunioQuoteParams, service: SunioService) => Promise<Result<SunioQuoteResponse, SwapErrorRight>>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchSunioQuote = void 0;
4
+ const monads_1 = require("@sniptt/monads");
5
+ const types_1 = require("../../../types");
6
+ const utils_1 = require("../../../utils");
7
+ const constants_1 = require("./constants");
8
+ const helpers_1 = require("./helpers/helpers");
9
+ const fetchSunioQuote = async (params, service) => {
10
+ try {
11
+ const { sellAssetId, buyAssetId, sellAmountCryptoBaseUnit } = params;
12
+ const fromToken = (0, helpers_1.assetIdToTronToken)(sellAssetId);
13
+ const toToken = (0, helpers_1.assetIdToTronToken)(buyAssetId);
14
+ const queryParams = {
15
+ fromToken,
16
+ toToken,
17
+ amountIn: sellAmountCryptoBaseUnit,
18
+ typeList: constants_1.SUNIO_DEX_TYPES,
19
+ };
20
+ const url = `${constants_1.SUNIO_API_BASE_URL}/swap/router`;
21
+ const maybeResponse = await service.get(url, {
22
+ params: queryParams,
23
+ });
24
+ if (maybeResponse.isErr()) {
25
+ return (0, monads_1.Err)(maybeResponse.unwrapErr());
26
+ }
27
+ const { data: response } = maybeResponse.unwrap();
28
+ if (response.code !== 0 || !response.data || response.data.length === 0) {
29
+ return (0, monads_1.Err)((0, utils_1.makeSwapErrorRight)({
30
+ message: `[Sun.io] ${response.message || 'No routes found'}`,
31
+ code: types_1.TradeQuoteError.NoRouteFound,
32
+ details: { response },
33
+ }));
34
+ }
35
+ return (0, monads_1.Ok)(response);
36
+ }
37
+ catch (error) {
38
+ return (0, monads_1.Err)((0, utils_1.makeSwapErrorRight)({
39
+ message: '[Sun.io] Failed to fetch quote',
40
+ code: types_1.TradeQuoteError.QueryFailed,
41
+ cause: error,
42
+ }));
43
+ }
44
+ };
45
+ exports.fetchSunioQuote = fetchSunioQuote;
@@ -0,0 +1,4 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { CommonTradeQuoteInput, GetTradeRateInput, GetTronTradeQuoteInput, SwapErrorRight, SwapperDeps, TradeQuote, TradeRate } from '../../../types';
3
+ export declare function getQuoteOrRate(input: GetTronTradeQuoteInput | CommonTradeQuoteInput, deps: SwapperDeps): Promise<Result<TradeQuote, SwapErrorRight>>;
4
+ export declare function getQuoteOrRate(input: GetTradeRateInput, deps: SwapperDeps): Promise<Result<TradeRate, SwapErrorRight>>;
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getQuoteOrRate = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
5
+ const utils_1 = require("@shapeshiftoss/utils");
6
+ const monads_1 = require("@sniptt/monads");
7
+ const tronweb_1 = require("tronweb");
8
+ const types_1 = require("../../../types");
9
+ const utils_2 = require("../../../utils");
10
+ const constants_1 = require("./constants");
11
+ const fetchFromSunio_1 = require("./fetchFromSunio");
12
+ const helpers_1 = require("./helpers/helpers");
13
+ const sunioService_1 = require("./sunioService");
14
+ async function getQuoteOrRate(input, deps) {
15
+ try {
16
+ const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, accountNumber, affiliateBps, slippageTolerancePercentageDecimal, } = input;
17
+ const { assertGetTronChainAdapter: _assertGetTronChainAdapter } = deps;
18
+ if (!(0, helpers_1.isSupportedChainId)(sellAsset.chainId)) {
19
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
20
+ message: `[${types_1.SwapperName.Sunio}] Unsupported chainId: ${sellAsset.chainId}`,
21
+ code: types_1.TradeQuoteError.UnsupportedChain,
22
+ details: { chainId: sellAsset.chainId },
23
+ }));
24
+ }
25
+ if (sellAsset.chainId !== buyAsset.chainId) {
26
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
27
+ message: `[${types_1.SwapperName.Sunio}] Cross-chain not supported`,
28
+ code: types_1.TradeQuoteError.CrossChainNotSupported,
29
+ }));
30
+ }
31
+ if (sellAsset.chainId !== caip_1.tronChainId) {
32
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
33
+ message: `[${types_1.SwapperName.Sunio}] Only TRON chain supported`,
34
+ code: types_1.TradeQuoteError.UnsupportedChain,
35
+ }));
36
+ }
37
+ const service = (0, sunioService_1.sunioServiceFactory)();
38
+ const maybeQuoteResponse = await (0, fetchFromSunio_1.fetchSunioQuote)({
39
+ sellAssetId: sellAsset.assetId,
40
+ buyAssetId: buyAsset.assetId,
41
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
42
+ }, service);
43
+ if (maybeQuoteResponse.isErr()) {
44
+ return (0, monads_1.Err)(maybeQuoteResponse.unwrapErr());
45
+ }
46
+ const quoteResponse = maybeQuoteResponse.unwrap();
47
+ const bestRoute = quoteResponse.data[0];
48
+ if (!bestRoute) {
49
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
50
+ message: '[Sun.io] No routes available',
51
+ code: types_1.TradeQuoteError.NoRouteFound,
52
+ }));
53
+ }
54
+ const isQuote = input.quoteOrRate === 'quote';
55
+ // For quotes, receiveAddress is required
56
+ if (isQuote && !receiveAddress) {
57
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
58
+ message: '[Sun.io] receiveAddress is required for quotes',
59
+ code: types_1.TradeQuoteError.InternalError,
60
+ }));
61
+ }
62
+ // Fetch network fees for both quotes and rates (when wallet connected)
63
+ let networkFeeCryptoBaseUnit = undefined;
64
+ // Estimate fees when we have an address to estimate from
65
+ if (receiveAddress) {
66
+ try {
67
+ const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
68
+ const isSellingNativeTrx = !contractAddress;
69
+ const tronWeb = new tronweb_1.TronWeb({ fullHost: deps.config.VITE_TRON_NODE_URL });
70
+ // Get chain parameters for pricing
71
+ const params = await tronWeb.trx.getChainParameters();
72
+ const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
73
+ const energyPrice = params.find(p => p.key === 'getEnergyFee')?.value ?? 100;
74
+ // Check if recipient needs activation (applies to all swaps)
75
+ let accountActivationFee = 0;
76
+ try {
77
+ const recipientInfoResponse = await fetch(`${deps.config.VITE_TRON_NODE_URL}/wallet/getaccount`, {
78
+ method: 'POST',
79
+ headers: { 'Content-Type': 'application/json' },
80
+ body: JSON.stringify({ address: receiveAddress, visible: true }),
81
+ });
82
+ const recipientInfo = await recipientInfoResponse.json();
83
+ const recipientExists = recipientInfo && Object.keys(recipientInfo).length > 1;
84
+ if (!recipientExists) {
85
+ accountActivationFee = 1_000_000; // 1 TRX
86
+ }
87
+ }
88
+ catch {
89
+ // Ignore activation check errors
90
+ }
91
+ // For native TRX swaps, Sun.io uses a contract call with value
92
+ // We need to estimate energy for the swap contract, not just bandwidth
93
+ if (isSellingNativeTrx) {
94
+ try {
95
+ // Sun.io contract owner provides most energy (~117k), users only pay ~2k
96
+ // Use fixed 2k energy estimate instead of querying (which returns total 120k)
97
+ const energyUsed = 2000; // User pays ~2k energy, contract covers the rest
98
+ const energyFee = energyUsed * energyPrice; // No multiplier - contract provides energy
99
+ // Estimate bandwidth for contract call (much larger than simple transfer)
100
+ const bandwidthFee = 1100 * bandwidthPrice; // ~1100 bytes for contract call (with safety buffer)
101
+ networkFeeCryptoBaseUnit = (0, utils_1.bn)(energyFee)
102
+ .plus(bandwidthFee)
103
+ .plus(accountActivationFee)
104
+ .toFixed(0);
105
+ }
106
+ catch (estimationError) {
107
+ // Fallback estimate: ~2k energy + ~1100 bytes bandwidth + activation fee
108
+ const fallbackEnergyFee = 2000 * energyPrice;
109
+ const fallbackBandwidthFee = 1100 * bandwidthPrice;
110
+ networkFeeCryptoBaseUnit = (0, utils_1.bn)(fallbackEnergyFee)
111
+ .plus(fallbackBandwidthFee)
112
+ .plus(accountActivationFee)
113
+ .toFixed(0);
114
+ }
115
+ }
116
+ else {
117
+ // For TRC-20 swaps through Sun.io router
118
+ // Same as TRX: contract owner provides most energy, user pays ~2k
119
+ // Sun.io provides ~217k energy, user pays ~2k
120
+ const energyFee = 2000 * energyPrice;
121
+ const bandwidthFee = 1100 * bandwidthPrice;
122
+ networkFeeCryptoBaseUnit = (0, utils_1.bn)(energyFee)
123
+ .plus(bandwidthFee)
124
+ .plus(accountActivationFee)
125
+ .toFixed(0);
126
+ }
127
+ }
128
+ catch (error) {
129
+ // For rates, fall back to '0' on estimation failure
130
+ // For quotes, let it error (required for accurate swap)
131
+ if (!isQuote) {
132
+ networkFeeCryptoBaseUnit = '0';
133
+ }
134
+ else {
135
+ throw error;
136
+ }
137
+ }
138
+ }
139
+ const buyAmountCryptoBaseUnit = (0, utils_1.bn)(bestRoute.amountOut)
140
+ .times((0, utils_1.bn)(10).pow(buyAsset.precision))
141
+ .toFixed(0);
142
+ // Calculate protocol fees only for quotes
143
+ const protocolFeeCryptoBaseUnit = isQuote
144
+ ? (0, utils_1.bn)(bestRoute.fee).times(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0)
145
+ : '0';
146
+ const buyAmountAfterFeesCryptoBaseUnit = buyAmountCryptoBaseUnit;
147
+ const rate = (0, utils_2.getInputOutputRate)({
148
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
149
+ buyAmountCryptoBaseUnit,
150
+ sellAsset,
151
+ buyAsset,
152
+ });
153
+ const trade = {
154
+ id: crypto.randomUUID(),
155
+ quoteOrRate: input.quoteOrRate,
156
+ rate,
157
+ slippageTolerancePercentageDecimal: slippageTolerancePercentageDecimal ?? constants_1.DEFAULT_SLIPPAGE_PERCENTAGE,
158
+ receiveAddress,
159
+ affiliateBps,
160
+ steps: [
161
+ {
162
+ buyAmountBeforeFeesCryptoBaseUnit: buyAmountCryptoBaseUnit,
163
+ buyAmountAfterFeesCryptoBaseUnit,
164
+ sellAmountIncludingProtocolFeesCryptoBaseUnit,
165
+ feeData: {
166
+ networkFeeCryptoBaseUnit,
167
+ protocolFees: protocolFeeCryptoBaseUnit !== '0'
168
+ ? {
169
+ [sellAsset.assetId]: {
170
+ amountCryptoBaseUnit: protocolFeeCryptoBaseUnit,
171
+ requiresBalance: false,
172
+ asset: sellAsset,
173
+ },
174
+ }
175
+ : {},
176
+ },
177
+ rate,
178
+ source: types_1.SwapperName.Sunio,
179
+ buyAsset,
180
+ sellAsset,
181
+ accountNumber,
182
+ allowanceContract: constants_1.SUNIO_SMART_ROUTER_CONTRACT,
183
+ estimatedExecutionTimeMs: undefined,
184
+ ...(isQuote && {
185
+ sunioTransactionMetadata: {
186
+ route: bestRoute,
187
+ },
188
+ }),
189
+ },
190
+ ],
191
+ swapperName: types_1.SwapperName.Sunio,
192
+ };
193
+ return (0, monads_1.Ok)(trade);
194
+ }
195
+ catch (error) {
196
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
197
+ message: `[Sun.io] Failed to get trade ${input.quoteOrRate}`,
198
+ code: types_1.TradeQuoteError.UnknownError,
199
+ cause: error,
200
+ }));
201
+ }
202
+ }
203
+ exports.getQuoteOrRate = getQuoteOrRate;
@@ -0,0 +1,4 @@
1
+ import type { AssetId } from '@shapeshiftoss/caip';
2
+ export declare const isSupportedChainId: (chainId: string) => boolean;
3
+ export declare const assetIdToTronToken: (assetId: AssetId) => string;
4
+ export declare const isTronChainId: (chainId: string) => chainId is import("@shapeshiftoss/caip").ChainId;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTronChainId = exports.assetIdToTronToken = exports.isSupportedChainId = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
5
+ const utils_1 = require("@shapeshiftoss/utils");
6
+ const constants_1 = require("../constants");
7
+ const isSupportedChainId = (chainId) => {
8
+ return constants_1.SUNIO_SUPPORTED_CHAIN_IDS.includes(chainId);
9
+ };
10
+ exports.isSupportedChainId = isSupportedChainId;
11
+ const assetIdToTronToken = (assetId) => {
12
+ if ((0, utils_1.isToken)(assetId)) {
13
+ const { assetReference } = (0, caip_1.fromAssetId)(assetId);
14
+ return assetReference;
15
+ }
16
+ return constants_1.SUNIO_TRON_NATIVE_ADDRESS;
17
+ };
18
+ exports.assetIdToTronToken = assetIdToTronToken;
19
+ const isTronChainId = (chainId) => {
20
+ return chainId === caip_1.tronChainId;
21
+ };
22
+ exports.isTronChainId = isTronChainId;
@@ -0,0 +1,6 @@
1
+ export declare const sunioServiceFactory: () => {
2
+ get: <T = any>(url: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@sniptt/monads").Result<import("axios").AxiosResponse<T, any, {}>, import("../../..").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("../../..").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("../../..").SwapErrorRight>>;
5
+ };
6
+ export type SunioService = ReturnType<typeof sunioServiceFactory>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sunioServiceFactory = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ const maxAge = 5 * 1000;
6
+ const cachedUrls = ['/swap/router'];
7
+ const sunioServiceFactory = () => {
8
+ const axiosConfig = {
9
+ timeout: 10000,
10
+ headers: {
11
+ Accept: 'application/json',
12
+ 'Content-Type': 'application/json',
13
+ },
14
+ };
15
+ const serviceBase = (0, utils_1.createCache)(maxAge, cachedUrls, axiosConfig);
16
+ return (0, utils_1.makeSwapperAxiosServiceMonadic)(serviceBase);
17
+ };
18
+ exports.sunioServiceFactory = sunioServiceFactory;
@@ -10,4 +10,7 @@ exports.thorchainSwapper = {
10
10
  executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => {
11
11
  return signAndBroadcastTransaction(txToSign);
12
12
  },
13
+ executeTronTransaction: (txToSign, { signAndBroadcastTransaction }) => {
14
+ return signAndBroadcastTransaction(txToSign);
15
+ },
13
16
  };
@@ -15,6 +15,8 @@ exports.thorchainApi = {
15
15
  getEvmTransactionFees: input => thorchain_utils_1.evm.getEvmTransactionFees(input, swapperName),
16
16
  getUnsignedUtxoTransaction: input => thorchain_utils_1.utxo.getUnsignedUtxoTransaction(input, swapperName),
17
17
  getUtxoTransactionFees: input => thorchain_utils_1.utxo.getUtxoTransactionFees(input, swapperName),
18
+ getUnsignedTronTransaction: input => thorchain_utils_1.tron.getUnsignedTronTransaction(input, swapperName),
19
+ getTronTransactionFees: input => thorchain_utils_1.tron.getTronTransactionFees(input, swapperName),
18
20
  getUnsignedCosmosSdkTransaction: async ({ tradeQuote, stepIndex, from, config, assertGetCosmosSdkChainAdapter, }) => {
19
21
  if (!(0, utils_1.isExecutableTradeQuote)(tradeQuote))
20
22
  throw new Error('Unable to execute a trade rate quote');
@@ -25,7 +25,6 @@
25
25
  "ETH.GUSD-0X056FD409E1D7A124BD7017459DFEA2F387B6D5CD": "eip155:1/erc20:0x056fd409e1d7a124bd7017459dfea2f387b6d5cd",
26
26
  "ETH.LINK-0X514910771AF9CA656AF840DFF83E8264ECF986CA": "eip155:1/erc20:0x514910771af9ca656af840dff83e8264ecf986ca",
27
27
  "ETH.LUSD-0X5F98805A4E8BE255A32880FDEC7F6728C6568BA0": "eip155:1/erc20:0x5f98805a4e8be255a32880fdec7f6728c6568ba0",
28
- "ETH.RAZE-0X5EAA69B29F99C84FE5DE8200340B4E9B4AB38EAC": "eip155:1/erc20:0x5eaa69b29f99c84fe5de8200340b4e9b4ab38eac",
29
28
  "ETH.SNX-0XC011A73EE8576FB46F5E1C5751CA3B9FE0AF2A6F": "eip155:1/erc20:0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",
30
29
  "ETH.TGT-0X108A850856DB3F85D0269A2693D896B394C80325": "eip155:1/erc20:0x108a850856db3f85d0269a2693d896b394c80325",
31
30
  "ETH.THOR-0XA5F2211B9B8170F694421F2046281775E8468044": "eip155:1/erc20:0xa5f2211b9b8170f694421f2046281775e8468044",
@@ -34,12 +33,13 @@
34
33
  "ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7": "eip155:1/erc20:0xdac17f958d2ee523a2206206994597c13d831ec7",
35
34
  "ETH.VTHOR-0X815C23ECA83261B6EC689B60CC4A58B54BC24D8D": "eip155:1/erc20:0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",
36
35
  "ETH.WBTC-0X2260FAC5E5542A773AA44FBCFEDF7C193BC2C599": "eip155:1/erc20:0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
37
- "ETH.XDEFI-0X72B886D09C117654AB7DA13A14D603001DE0B777": "eip155:1/erc20:0x72b886d09c117654ab7da13a14d603001de0b777",
38
36
  "ETH.XRUNE-0X69FA0FEE221AD11012BAB0FDB45D444D3D2CE71C": "eip155:1/erc20:0x69fa0fee221ad11012bab0fdb45d444d3d2ce71c",
39
37
  "ETH.YFI-0X0BC529C00C6401AEF6D220BE8C6EA1667F6AD93E": "eip155:1/erc20:0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",
40
38
  "GAIA.ATOM": "cosmos:cosmoshub-4/slip44:118",
41
39
  "LTC.LTC": "bip122:12a765e31ffd4059bada1e25190f6e98/slip44:2",
42
40
  "THOR.RUJI": "cosmos:thorchain-1/slip44:ruji",
43
41
  "THOR.TCY": "cosmos:thorchain-1/slip44:tcy",
42
+ "TRON.TRX": "tron:0x2b6653dc/slip44:195",
43
+ "TRON.USDT-TR7NHQJEKQXGTCI8Q8ZY4PL8OTSZGJLJ6T": "tron:0x2b6653dc/trc20:tr7nhqjekqxgtci8q8zy4pl8otszgjlj6t",
44
44
  "THOR.RUNE": "cosmos:thorchain-1/slip44:931"
45
45
  }