@shapeshiftoss/swapper 17.6.7 → 17.6.9

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 +10 -4
  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 +10 -4
  218. package/dist/esm/utils.js +50 -1
  219. package/package.json +5 -4
@@ -1,6 +1,8 @@
1
1
  import { assertUnreachable } from '@shapeshiftoss/utils';
2
2
  import { arbitrumBridgeSwapper } from './swappers/ArbitrumBridgeSwapper/ArbitrumBridgeSwapper.js';
3
3
  import { arbitrumBridgeApi } from './swappers/ArbitrumBridgeSwapper/endpoints.js';
4
+ import { avnuSwapper } from './swappers/AvnuSwapper/AvnuSwapper.js';
5
+ import { avnuApi } from './swappers/AvnuSwapper/endpoints.js';
4
6
  import { bebopSwapper } from './swappers/BebopSwapper/BebopSwapper.js';
5
7
  import { bebopApi } from './swappers/BebopSwapper/endpoints.js';
6
8
  import { butterSwap } from './swappers/ButterSwap/ButterSwap.js';
@@ -21,6 +23,8 @@ import { portalsApi } from './swappers/PortalsSwapper/endpoints.js';
21
23
  import { portalsSwapper } from './swappers/PortalsSwapper/PortalsSwapper.js';
22
24
  import { relaySwapper } from './swappers/RelaySwapper/index.js';
23
25
  import { relayApi } from './swappers/RelaySwapper/endpoints.js';
26
+ import { sunioApi } from './swappers/SunioSwapper/endpoints.js';
27
+ import { sunioSwapper } from './swappers/SunioSwapper/SunioSwapper.js';
24
28
  import { thorchainApi } from './swappers/ThorchainSwapper/endpoints.js';
25
29
  import { thorchainSwapper } from './swappers/ThorchainSwapper/ThorchainSwapper.js';
26
30
  import { zrxApi } from './swappers/ZrxSwapper/endpoints.js';
@@ -87,6 +91,14 @@ export const swappers = {
87
91
  ...cetusSwapper,
88
92
  ...cetusApi,
89
93
  },
94
+ [SwapperName.Sunio]: {
95
+ ...sunioSwapper,
96
+ ...sunioApi,
97
+ },
98
+ [SwapperName.Avnu]: {
99
+ ...avnuSwapper,
100
+ ...avnuApi,
101
+ },
90
102
  [SwapperName.Test]: undefined,
91
103
  };
92
104
  // Slippage defaults. Don't export these to ensure the getDefaultSlippageDecimalPercentageForSwapper helper function is used.
@@ -100,6 +112,8 @@ const DEFAULT_ARBITRUM_BRIDGE_SLIPPAGE_DECIMAL_PERCENTAGE = '0'; // no slippage
100
112
  const DEFAULT_CHAINFLIP_SLIPPAGE_DECIMAL_PERCENTAGE = '0.02'; // 2%
101
113
  const DEFAULT_BUTTERSWAP_SLIPPAGE_DECIMAL_PERCENTAGE = '0.015'; // 1.5%
102
114
  const DEFAULT_CETUS_SLIPPAGE_DECIMAL_PERCENTAGE = '0.005'; // .5%
115
+ const DEFAULT_SUNIO_SLIPPAGE_DECIMAL_PERCENTAGE = '0.005'; // .5%
116
+ const DEFAULT_AVNU_SLIPPAGE_DECIMAL_PERCENTAGE = '0.005'; // .5%
103
117
  export const getDefaultSlippageDecimalPercentageForSwapper = (swapperName) => {
104
118
  if (swapperName === undefined)
105
119
  return DEFAULT_SLIPPAGE_DECIMAL_PERCENTAGE;
@@ -130,6 +144,10 @@ export const getDefaultSlippageDecimalPercentageForSwapper = (swapperName) => {
130
144
  return DEFAULT_NEAR_INTENTS_SLIPPAGE_DECIMAL_PERCENTAGE;
131
145
  case SwapperName.Cetus:
132
146
  return DEFAULT_CETUS_SLIPPAGE_DECIMAL_PERCENTAGE;
147
+ case SwapperName.Sunio:
148
+ return DEFAULT_SUNIO_SLIPPAGE_DECIMAL_PERCENTAGE;
149
+ case SwapperName.Avnu:
150
+ return DEFAULT_AVNU_SLIPPAGE_DECIMAL_PERCENTAGE;
133
151
  default:
134
152
  return assertUnreachable(swapperName);
135
153
  }
@@ -23,6 +23,7 @@ export const SUPPORTED_CHAIN_IDS = [
23
23
  KnownChainIds.BaseMainnet,
24
24
  KnownChainIds.AvalancheMainnet,
25
25
  KnownChainIds.PolygonMainnet,
26
+ KnownChainIds.BnbSmartChainMainnet,
26
27
  ];
27
28
  export const COW_SWAP_VAULT_RELAYER_ADDRESS = '0xc92e8bdf79f0507f65a392b0ab4667716bfe0110';
28
29
  export const COW_SWAP_SETTLEMENT_ADDRESS = '0x9008D19f58AAbD9eD0D60971565AA8510560ab41';
@@ -22,6 +22,8 @@ export const getCowNetwork = (chainId) => {
22
22
  return CowNetwork.Avalanche;
23
23
  case KnownChainIds.PolygonMainnet:
24
24
  return CowNetwork.Polygon;
25
+ case KnownChainIds.BnbSmartChainMainnet:
26
+ return CowNetwork.Bnb;
25
27
  default:
26
28
  return;
27
29
  }
@@ -3,9 +3,11 @@ export * from './cowswap-utils/index.js';
3
3
  export * from './safe-utils/index.js';
4
4
  export * from './swapper.js';
5
5
  export * from './swappers/ArbitrumBridgeSwapper/index.js';
6
+ export * from './swappers/AvnuSwapper/index.js';
6
7
  export * from './swappers/BebopSwapper/index.js';
7
8
  export * from './swappers/CetusSwapper/index.js';
8
9
  export * from './swappers/ChainflipSwapper/index.js';
10
+ export * from './swappers/SunioSwapper/index.js';
9
11
  export * from './swappers/CowSwapper/index.js';
10
12
  export * from './swappers/JupiterSwapper/index.js';
11
13
  export * from './swappers/PortalsSwapper/index.js';
package/dist/esm/index.js CHANGED
@@ -3,9 +3,11 @@ export * from './cowswap-utils/index.js';
3
3
  export * from './safe-utils/index.js';
4
4
  export * from './swapper.js';
5
5
  export * from './swappers/ArbitrumBridgeSwapper/index.js';
6
+ export * from './swappers/AvnuSwapper/index.js';
6
7
  export * from './swappers/BebopSwapper/index.js';
7
8
  export * from './swappers/CetusSwapper/index.js';
8
9
  export * from './swappers/ChainflipSwapper/index.js';
10
+ export * from './swappers/SunioSwapper/index.js';
9
11
  export * from './swappers/CowSwapper/index.js';
10
12
  export * from './swappers/JupiterSwapper/index.js';
11
13
  export * from './swappers/PortalsSwapper/index.js';
@@ -0,0 +1,2 @@
1
+ import type { Swapper } from '../../types.js';
2
+ export declare const avnuSwapper: Swapper;
@@ -0,0 +1,4 @@
1
+ import { executeStarknetTransaction } from '../../index.js';
2
+ export const avnuSwapper = {
3
+ executeStarknetTransaction,
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { SwapperApi } from '../../types.js';
2
+ export declare const avnuApi: SwapperApi;
@@ -0,0 +1,178 @@
1
+ import { quoteToCalls } from '@avnu/avnu-sdk';
2
+ import { toAddressNList } from '@shapeshiftoss/chain-adapters';
3
+ import { CallData, hash, num } from 'starknet';
4
+ import { checkStarknetSwapStatus, createDefaultStatusResponse, getExecutableTradeStep, isExecutableTradeQuote, } from '../../utils.js';
5
+ import { getTradeQuote } from './swapperApi/getTradeQuote.js';
6
+ import { getTradeRate } from './swapperApi/getTradeRate.js';
7
+ export const avnuApi = {
8
+ getTradeQuote,
9
+ getTradeRate: (input, deps) => {
10
+ return getTradeRate(input, deps);
11
+ },
12
+ getUnsignedStarknetTransaction: async ({ stepIndex, tradeQuote, from, slippageTolerancePercentageDecimal, assertGetStarknetChainAdapter, }) => {
13
+ if (!isExecutableTradeQuote(tradeQuote))
14
+ throw new Error('Unable to execute a trade rate quote');
15
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
16
+ const { accountNumber, sellAsset, avnuSpecific } = step;
17
+ if (!avnuSpecific)
18
+ throw new Error('avnuSpecific is required');
19
+ if (!avnuSpecific.quoteId)
20
+ throw new Error('quoteId is required in avnuSpecific');
21
+ const adapter = assertGetStarknetChainAdapter(sellAsset.chainId);
22
+ // Convert slippage from decimal percentage string to number for AVNU format (e.g., "0.01" = 1%)
23
+ const slippage = slippageTolerancePercentageDecimal
24
+ ? parseFloat(slippageTolerancePercentageDecimal)
25
+ : 0.01;
26
+ // Get the swap calls from AVNU SDK
27
+ const { calls: avnuCalls } = await quoteToCalls({
28
+ quoteId: avnuSpecific.quoteId,
29
+ slippage,
30
+ takerAddress: from,
31
+ });
32
+ // Build the full invoke transaction calldata from AVNU calls
33
+ // Format: [call_array_length, contract1, selector1, calldata_len1, ...calldata1, ...]
34
+ const fullCalldata = [avnuCalls.length.toString()];
35
+ for (const call of avnuCalls) {
36
+ const rawCalldata = call.calldata ?? [];
37
+ const calldataArray = Array.isArray(rawCalldata) ? rawCalldata : CallData.compile(rawCalldata);
38
+ const selector = hash.getSelectorFromName(call.entrypoint);
39
+ fullCalldata.push(call.contractAddress, selector, calldataArray.length.toString(), ...calldataArray.map(cd => cd.toString()));
40
+ }
41
+ // Format calldata for RPC (convert numbers to hex)
42
+ const formattedCalldata = fullCalldata.map(data => {
43
+ if (!data.startsWith('0x')) {
44
+ return num.toHex(data);
45
+ }
46
+ return data;
47
+ });
48
+ // Get nonce using adapter method (checks deployment status and returns appropriate nonce)
49
+ const chainIdHex = await adapter.getStarknetProvider().getChainId();
50
+ const nonce = await adapter.getNonce(from);
51
+ // Estimate fees for the multi-call swap transaction
52
+ const version = '0x3';
53
+ const estimateTx = {
54
+ type: 'INVOKE',
55
+ version,
56
+ sender_address: from,
57
+ calldata: formattedCalldata,
58
+ signature: [],
59
+ nonce,
60
+ resource_bounds: {
61
+ l1_gas: { max_amount: '0x186a0', max_price_per_unit: '0x5f5e100' },
62
+ l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' },
63
+ l1_data_gas: { max_amount: '0x186a0', max_price_per_unit: '0x1' },
64
+ },
65
+ tip: '0x0',
66
+ paymaster_data: [],
67
+ account_deployment_data: [],
68
+ nonce_data_availability_mode: 'L1',
69
+ fee_data_availability_mode: 'L1',
70
+ };
71
+ const estimateResponse = await adapter
72
+ .getStarknetProvider()
73
+ .fetch('starknet_estimateFee', [[estimateTx], ['SKIP_VALIDATE'], 'latest']);
74
+ const estimateResult = await estimateResponse.json();
75
+ if (estimateResult.error) {
76
+ throw new Error(`Fee estimation failed: ${JSON.stringify(estimateResult.error)}`);
77
+ }
78
+ const feeEstimate = estimateResult.result?.[0];
79
+ if (!feeEstimate) {
80
+ throw new Error('Fee estimation failed: no estimate returned');
81
+ }
82
+ // Calculate resource bounds with buffer (5x gas amount, 2x gas price)
83
+ const l1GasConsumed = feeEstimate.l1_gas_consumed
84
+ ? BigInt(feeEstimate.l1_gas_consumed)
85
+ : BigInt('0x186a0');
86
+ const l1GasPrice = feeEstimate.l1_gas_price
87
+ ? BigInt(feeEstimate.l1_gas_price)
88
+ : BigInt('0x5f5e100');
89
+ const l2GasConsumed = feeEstimate.l2_gas_consumed
90
+ ? BigInt(feeEstimate.l2_gas_consumed)
91
+ : BigInt('0x0');
92
+ const l2GasPrice = feeEstimate.l2_gas_price ? BigInt(feeEstimate.l2_gas_price) : BigInt('0x0');
93
+ const l1DataGasConsumed = feeEstimate.l1_data_gas_consumed
94
+ ? BigInt(feeEstimate.l1_data_gas_consumed)
95
+ : BigInt('0x186a0');
96
+ const l1DataGasPrice = feeEstimate.l1_data_gas_price
97
+ ? BigInt(feeEstimate.l1_data_gas_price)
98
+ : BigInt('0x1');
99
+ const resourceBounds = {
100
+ l1_gas: {
101
+ max_amount: (l1GasConsumed * BigInt(500)) / BigInt(100),
102
+ max_price_per_unit: (l1GasPrice * BigInt(200)) / BigInt(100),
103
+ },
104
+ l2_gas: {
105
+ max_amount: (l2GasConsumed * BigInt(500)) / BigInt(100),
106
+ max_price_per_unit: (l2GasPrice * BigInt(200)) / BigInt(100),
107
+ },
108
+ l1_data_gas: {
109
+ max_amount: (l1DataGasConsumed * BigInt(500)) / BigInt(100),
110
+ max_price_per_unit: (l1DataGasPrice * BigInt(200)) / BigInt(100),
111
+ },
112
+ };
113
+ // Calculate transaction hash for signing
114
+ const invokeHashInputs = {
115
+ senderAddress: from,
116
+ version,
117
+ compiledCalldata: formattedCalldata,
118
+ chainId: chainIdHex,
119
+ nonce,
120
+ nonceDataAvailabilityMode: 0,
121
+ feeDataAvailabilityMode: 0,
122
+ resourceBounds: {
123
+ l1_gas: {
124
+ max_amount: resourceBounds.l1_gas.max_amount,
125
+ max_price_per_unit: resourceBounds.l1_gas.max_price_per_unit,
126
+ },
127
+ l2_gas: {
128
+ max_amount: resourceBounds.l2_gas.max_amount,
129
+ max_price_per_unit: resourceBounds.l2_gas.max_price_per_unit,
130
+ },
131
+ l1_data_gas: {
132
+ max_amount: resourceBounds.l1_data_gas.max_amount,
133
+ max_price_per_unit: resourceBounds.l1_data_gas.max_price_per_unit,
134
+ },
135
+ },
136
+ tip: '0x0',
137
+ paymasterData: [],
138
+ accountDeploymentData: [],
139
+ };
140
+ const txHash = hash.calculateInvokeTransactionHash(invokeHashInputs);
141
+ // Return transaction ready for signing
142
+ return {
143
+ addressNList: toAddressNList(adapter.getBip44Params({ accountNumber })),
144
+ txHash,
145
+ _txDetails: {
146
+ fromAddress: from,
147
+ calldata: formattedCalldata,
148
+ nonce,
149
+ version,
150
+ resourceBounds,
151
+ chainId: chainIdHex,
152
+ nonceDataAvailabilityMode: 0,
153
+ feeDataAvailabilityMode: 0,
154
+ tip: '0x0',
155
+ paymasterData: [],
156
+ accountDeploymentData: [],
157
+ },
158
+ };
159
+ },
160
+ getStarknetTransactionFees: ({ tradeQuote, stepIndex }) => {
161
+ if (!isExecutableTradeQuote(tradeQuote))
162
+ throw new Error('Unable to execute a trade rate quote');
163
+ const step = getExecutableTradeStep(tradeQuote, stepIndex);
164
+ if (!step.feeData.networkFeeCryptoBaseUnit) {
165
+ throw new Error('Missing network fee in quote');
166
+ }
167
+ return Promise.resolve(step.feeData.networkFeeCryptoBaseUnit);
168
+ },
169
+ checkTradeStatus: ({ swap, assertGetStarknetChainAdapter }) => {
170
+ if (!swap?.sellTxHash) {
171
+ return Promise.resolve(createDefaultStatusResponse());
172
+ }
173
+ return checkStarknetSwapStatus({
174
+ txHash: swap.sellTxHash,
175
+ assertGetStarknetChainAdapter,
176
+ });
177
+ },
178
+ };
@@ -0,0 +1 @@
1
+ export { AVNU_SUPPORTED_CHAIN_IDS } from './utils/constants.js';
@@ -0,0 +1 @@
1
+ export { AVNU_SUPPORTED_CHAIN_IDS } from './utils/constants.js';
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { CommonTradeQuoteInput, SwapErrorRight, SwapperDeps, TradeQuote } from '../../../types.js';
3
+ export declare const getTradeQuote: (input: CommonTradeQuoteInput, deps: SwapperDeps) => Promise<Result<TradeQuote[], SwapErrorRight>>;
@@ -0,0 +1,138 @@
1
+ import { getQuotes } from '@avnu/avnu-sdk';
2
+ import { bn } from '@shapeshiftoss/utils';
3
+ import { Err, Ok } from '@sniptt/monads';
4
+ import { getTreasuryAddressFromChainId } from '../../utils/helpers/helpers.js';
5
+ import { v4 as uuid } from 'uuid';
6
+ import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
7
+ import { SwapperName, TradeQuoteError } from '../../../types.js';
8
+ import { getInputOutputRate, makeSwapErrorRight } from '../../../utils.js';
9
+ import { AVNU_SUPPORTED_CHAIN_IDS } from '../utils/constants.js';
10
+ import { getTokenAddress } from '../utils/helpers.js';
11
+ export const getTradeQuote = async (input, deps) => {
12
+ const { sellAsset, buyAsset, accountNumber, sendAddress, receiveAddress, sellAmountIncludingProtocolFeesCryptoBaseUnit: sellAmount, slippageTolerancePercentageDecimal, affiliateBps, } = input;
13
+ if (!AVNU_SUPPORTED_CHAIN_IDS.includes(sellAsset.chainId)) {
14
+ return Err(makeSwapErrorRight({
15
+ message: `Chain ${sellAsset.chainId} is not supported by AVNU`,
16
+ code: TradeQuoteError.UnsupportedChain,
17
+ }));
18
+ }
19
+ if (!AVNU_SUPPORTED_CHAIN_IDS.includes(buyAsset.chainId)) {
20
+ return Err(makeSwapErrorRight({
21
+ message: `Chain ${buyAsset.chainId} is not supported by AVNU`,
22
+ code: TradeQuoteError.UnsupportedChain,
23
+ }));
24
+ }
25
+ if (accountNumber === undefined) {
26
+ return Err(makeSwapErrorRight({
27
+ message: `accountNumber is required`,
28
+ code: TradeQuoteError.UnknownError,
29
+ }));
30
+ }
31
+ if (sendAddress === undefined) {
32
+ return Err(makeSwapErrorRight({
33
+ message: `sendAddress is required`,
34
+ code: TradeQuoteError.UnknownError,
35
+ }));
36
+ }
37
+ if (receiveAddress === undefined) {
38
+ return Err(makeSwapErrorRight({
39
+ message: `receiveAddress is required`,
40
+ code: TradeQuoteError.UnknownError,
41
+ }));
42
+ }
43
+ try {
44
+ const sellTokenAddress = getTokenAddress(sellAsset);
45
+ const buyTokenAddress = getTokenAddress(buyAsset);
46
+ const quotes = await getQuotes({
47
+ sellTokenAddress,
48
+ buyTokenAddress,
49
+ sellAmount: BigInt(sellAmount),
50
+ takerAddress: sendAddress,
51
+ size: 1,
52
+ integratorFees: affiliateBps ? BigInt(affiliateBps) : undefined,
53
+ integratorFeeRecipient: getTreasuryAddressFromChainId(sellAsset.chainId),
54
+ });
55
+ if (!quotes || quotes.length === 0) {
56
+ return Err(makeSwapErrorRight({
57
+ message: 'No quotes available for this trade pair',
58
+ code: TradeQuoteError.NoRouteFound,
59
+ }));
60
+ }
61
+ const bestQuote = quotes[0];
62
+ if (!bestQuote) {
63
+ return Err(makeSwapErrorRight({
64
+ message: 'No valid quote returned from AVNU',
65
+ code: TradeQuoteError.QueryFailed,
66
+ }));
67
+ }
68
+ const buyAmountAfterFeesCryptoBaseUnit = bestQuote.buyAmount.toString();
69
+ const sellAdapter = deps.assertGetStarknetChainAdapter(sellAsset.chainId);
70
+ const feeData = await sellAdapter.getFeeData({
71
+ to: receiveAddress,
72
+ value: sellAmount,
73
+ chainSpecific: {
74
+ from: sendAddress,
75
+ tokenContractAddress: sellTokenAddress,
76
+ },
77
+ sendMax: false,
78
+ });
79
+ const rate = getInputOutputRate({
80
+ sellAmountCryptoBaseUnit: sellAmount,
81
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
82
+ sellAsset,
83
+ buyAsset,
84
+ });
85
+ const protocolFees = affiliateBps
86
+ ? {
87
+ [buyAsset.assetId]: {
88
+ amountCryptoBaseUnit: bn(buyAmountAfterFeesCryptoBaseUnit)
89
+ .times(affiliateBps)
90
+ .div(10000)
91
+ .toFixed(0),
92
+ requiresBalance: false,
93
+ asset: buyAsset,
94
+ },
95
+ }
96
+ : {};
97
+ const tradeQuote = {
98
+ id: uuid(),
99
+ receiveAddress,
100
+ affiliateBps,
101
+ rate,
102
+ slippageTolerancePercentageDecimal: slippageTolerancePercentageDecimal ??
103
+ getDefaultSlippageDecimalPercentageForSwapper(SwapperName.Avnu),
104
+ quoteOrRate: 'quote',
105
+ swapperName: SwapperName.Avnu,
106
+ steps: [
107
+ {
108
+ accountNumber,
109
+ allowanceContract: '0x0',
110
+ buyAmountBeforeFeesCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
111
+ buyAmountAfterFeesCryptoBaseUnit,
112
+ buyAsset,
113
+ feeData: {
114
+ protocolFees,
115
+ networkFeeCryptoBaseUnit: feeData.fast.txFee,
116
+ },
117
+ rate,
118
+ sellAmountIncludingProtocolFeesCryptoBaseUnit: sellAmount,
119
+ sellAsset,
120
+ source: SwapperName.Avnu,
121
+ estimatedExecutionTimeMs: undefined,
122
+ avnuSpecific: {
123
+ quoteId: bestQuote.quoteId,
124
+ routes: bestQuote.routes,
125
+ },
126
+ },
127
+ ],
128
+ };
129
+ return Ok([tradeQuote]);
130
+ }
131
+ catch (error) {
132
+ return Err(makeSwapErrorRight({
133
+ message: error instanceof Error ? error.message : 'Unknown error getting AVNU quote',
134
+ code: TradeQuoteError.QueryFailed,
135
+ cause: error,
136
+ }));
137
+ }
138
+ };
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { GetTradeRateInput, SwapErrorRight, SwapperDeps, TradeRate } from '../../../types.js';
3
+ export declare const getTradeRate: (input: GetTradeRateInput, deps: SwapperDeps) => Promise<Result<TradeRate[], SwapErrorRight>>;
@@ -0,0 +1,116 @@
1
+ import { getQuotes } from '@avnu/avnu-sdk';
2
+ import { bn } from '@shapeshiftoss/utils';
3
+ import { Err, Ok } from '@sniptt/monads';
4
+ import { getTreasuryAddressFromChainId } from '../../utils/helpers/helpers.js';
5
+ import { v4 as uuid } from 'uuid';
6
+ import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants.js';
7
+ import { SwapperName, TradeQuoteError } from '../../../types.js';
8
+ import { getInputOutputRate, makeSwapErrorRight } from '../../../utils.js';
9
+ import { AVNU_SUPPORTED_CHAIN_IDS } from '../utils/constants.js';
10
+ import { getTokenAddress } from '../utils/helpers.js';
11
+ export const getTradeRate = async (input, deps) => {
12
+ const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit: sellAmount, slippageTolerancePercentageDecimal, affiliateBps, receiveAddress, } = input;
13
+ if (!AVNU_SUPPORTED_CHAIN_IDS.includes(sellAsset.chainId)) {
14
+ return Err(makeSwapErrorRight({
15
+ message: `Chain ${sellAsset.chainId} is not supported by AVNU`,
16
+ code: TradeQuoteError.UnsupportedChain,
17
+ }));
18
+ }
19
+ if (!AVNU_SUPPORTED_CHAIN_IDS.includes(buyAsset.chainId)) {
20
+ return Err(makeSwapErrorRight({
21
+ message: `Chain ${buyAsset.chainId} is not supported by AVNU`,
22
+ code: TradeQuoteError.UnsupportedChain,
23
+ }));
24
+ }
25
+ try {
26
+ const sellTokenAddress = getTokenAddress(sellAsset);
27
+ const buyTokenAddress = getTokenAddress(buyAsset);
28
+ const quotes = await getQuotes({
29
+ sellTokenAddress,
30
+ buyTokenAddress,
31
+ sellAmount: BigInt(sellAmount),
32
+ size: 1,
33
+ integratorFees: affiliateBps ? BigInt(affiliateBps) : undefined,
34
+ integratorFeeRecipient: getTreasuryAddressFromChainId(sellAsset.chainId),
35
+ });
36
+ if (!quotes || quotes.length === 0) {
37
+ return Err(makeSwapErrorRight({
38
+ message: 'No quotes available for this trade pair',
39
+ code: TradeQuoteError.NoRouteFound,
40
+ }));
41
+ }
42
+ const bestQuote = quotes[0];
43
+ if (!bestQuote) {
44
+ return Err(makeSwapErrorRight({
45
+ message: 'No valid quote returned from AVNU',
46
+ code: TradeQuoteError.QueryFailed,
47
+ }));
48
+ }
49
+ const buyAmountAfterFeesCryptoBaseUnit = bestQuote.buyAmount.toString();
50
+ const sellAdapter = deps.assertGetStarknetChainAdapter(sellAsset.chainId);
51
+ // For rate quotes, use receiveAddress as a dummy from/to for fee estimation
52
+ const feeData = await sellAdapter.getFeeData({
53
+ to: receiveAddress ?? '',
54
+ value: sellAmount,
55
+ chainSpecific: {
56
+ from: receiveAddress ?? '',
57
+ tokenContractAddress: sellTokenAddress,
58
+ },
59
+ sendMax: false,
60
+ });
61
+ const rate = getInputOutputRate({
62
+ sellAmountCryptoBaseUnit: sellAmount,
63
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
64
+ sellAsset,
65
+ buyAsset,
66
+ });
67
+ const protocolFees = affiliateBps
68
+ ? {
69
+ [buyAsset.assetId]: {
70
+ amountCryptoBaseUnit: bn(buyAmountAfterFeesCryptoBaseUnit)
71
+ .times(affiliateBps)
72
+ .div(10000)
73
+ .toFixed(0),
74
+ requiresBalance: false,
75
+ asset: buyAsset,
76
+ },
77
+ }
78
+ : {};
79
+ const tradeRate = {
80
+ id: uuid(),
81
+ receiveAddress,
82
+ affiliateBps,
83
+ rate,
84
+ slippageTolerancePercentageDecimal: slippageTolerancePercentageDecimal ??
85
+ getDefaultSlippageDecimalPercentageForSwapper(SwapperName.Avnu),
86
+ quoteOrRate: 'rate',
87
+ swapperName: SwapperName.Avnu,
88
+ steps: [
89
+ {
90
+ accountNumber: undefined,
91
+ allowanceContract: '0x0',
92
+ buyAmountBeforeFeesCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
93
+ buyAmountAfterFeesCryptoBaseUnit,
94
+ buyAsset,
95
+ feeData: {
96
+ protocolFees,
97
+ networkFeeCryptoBaseUnit: feeData.fast.txFee,
98
+ },
99
+ rate,
100
+ sellAmountIncludingProtocolFeesCryptoBaseUnit: sellAmount,
101
+ sellAsset,
102
+ source: SwapperName.Avnu,
103
+ estimatedExecutionTimeMs: undefined,
104
+ },
105
+ ],
106
+ };
107
+ return Ok([tradeRate]);
108
+ }
109
+ catch (error) {
110
+ return Err(makeSwapErrorRight({
111
+ message: error instanceof Error ? error.message : 'Unknown error getting AVNU rate',
112
+ code: TradeQuoteError.QueryFailed,
113
+ cause: error,
114
+ }));
115
+ }
116
+ };
@@ -0,0 +1,2 @@
1
+ import type { KnownChainIds } from '@shapeshiftoss/types';
2
+ export type AvnuSupportedChainId = typeof KnownChainIds.StarknetMainnet;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ChainId } from '@shapeshiftoss/caip';
2
+ export declare const AVNU_SUPPORTED_CHAIN_IDS: readonly ChainId[];
3
+ export declare const isSupportedChainId: (chainId: ChainId) => chainId is ChainId;
4
+ export declare const DEFAULT_SLIPPAGE_PERCENTAGE = "0.005";
5
+ export declare const AVNU_API_BASE_URL = "https://starknet.api.avnu.fi";
@@ -0,0 +1,7 @@
1
+ import { KnownChainIds } from '@shapeshiftoss/types';
2
+ export const AVNU_SUPPORTED_CHAIN_IDS = [KnownChainIds.StarknetMainnet];
3
+ export const isSupportedChainId = (chainId) => {
4
+ return AVNU_SUPPORTED_CHAIN_IDS.includes(chainId);
5
+ };
6
+ export const DEFAULT_SLIPPAGE_PERCENTAGE = '0.005';
7
+ export const AVNU_API_BASE_URL = 'https://starknet.api.avnu.fi';
@@ -0,0 +1,7 @@
1
+ import type { Asset } from '@shapeshiftoss/types';
2
+ /**
3
+ * Get the token address for AVNU swaps
4
+ * For native STRK token (slip44 namespace), returns the STRK contract address
5
+ * For other tokens, returns the token contract address from assetReference
6
+ */
7
+ export declare const getTokenAddress: (asset: Asset) => string;
@@ -0,0 +1,17 @@
1
+ import { fromAssetId } from '@shapeshiftoss/caip';
2
+ // STRK native token contract address on Starknet
3
+ const AVNU_STRK_NATIVE_ADDRESS = '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d';
4
+ /**
5
+ * Get the token address for AVNU swaps
6
+ * For native STRK token (slip44 namespace), returns the STRK contract address
7
+ * For other tokens, returns the token contract address from assetReference
8
+ */
9
+ export const getTokenAddress = (asset) => {
10
+ const { assetReference, assetNamespace } = fromAssetId(asset.assetId);
11
+ // For native STRK token, the assetReference is 'slip44:9004' but AVNU expects the STRK contract address
12
+ if (assetNamespace === 'slip44') {
13
+ return AVNU_STRK_NATIVE_ADDRESS;
14
+ }
15
+ // For other tokens, the assetReference should be the token contract address
16
+ return assetReference;
17
+ };
@@ -32,6 +32,8 @@ describe('getTradeQuote', () => {
32
32
  assertGetSolanaChainAdapter: () => vi.fn(),
33
33
  assertGetTronChainAdapter: () => vi.fn(),
34
34
  assertGetSuiChainAdapter: () => vi.fn(),
35
+ assertGetNearChainAdapter: () => vi.fn(),
36
+ assertGetStarknetChainAdapter: () => vi.fn(),
35
37
  config: {
36
38
  VITE_BUTTERSWAP_CLIENT_ID: 'test',
37
39
  },
@@ -23,6 +23,8 @@ describe('getTradeRate', () => {
23
23
  assertGetSolanaChainAdapter: () => vi.fn(),
24
24
  assertGetTronChainAdapter: () => vi.fn(),
25
25
  assertGetSuiChainAdapter: () => vi.fn(),
26
+ assertGetNearChainAdapter: () => vi.fn(),
27
+ assertGetStarknetChainAdapter: () => vi.fn(),
26
28
  config: {
27
29
  VITE_BUTTERSWAP_CLIENT_ID: 'test',
28
30
  },
@@ -57,6 +59,8 @@ describe('getTradeRate', () => {
57
59
  assertGetSolanaChainAdapter: () => vi.fn(),
58
60
  assertGetTronChainAdapter: () => vi.fn(),
59
61
  assertGetSuiChainAdapter: () => vi.fn(),
62
+ assertGetNearChainAdapter: () => vi.fn(),
63
+ assertGetStarknetChainAdapter: () => vi.fn(),
60
64
  config: {
61
65
  VITE_BUTTERSWAP_CLIENT_ID: 'test',
62
66
  },
@@ -7,6 +7,7 @@ const BUTTERSWAP_CHAIN_ID_TO_CHAIN_ID = {
7
7
  42161: KnownChainIds.ArbitrumMainnet,
8
8
  10: KnownChainIds.OptimismMainnet,
9
9
  8453: KnownChainIds.BaseMainnet,
10
+ 43114: KnownChainIds.AvalancheMainnet,
10
11
  1360108768460801: KnownChainIds.SolanaMainnet,
11
12
  1360095883558913: KnownChainIds.BitcoinMainnet,
12
13
  };