@shapeshiftoss/swapper 17.6.10 → 17.6.11

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 (192) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/constants.js +29 -18
  4. package/dist/cjs/cowswap-utils/constants.js +3 -0
  5. package/dist/cjs/cowswap-utils/index.js +6 -0
  6. package/dist/cjs/index.d.ts +1 -0
  7. package/dist/cjs/index.js +1 -0
  8. package/dist/cjs/swappers/AcrossSwapper/constant.js +2 -0
  9. package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +15 -1
  10. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +9 -0
  11. package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.js +9 -0
  12. package/dist/cjs/swappers/BebopSwapper/BebopSwapper.js +2 -0
  13. package/dist/cjs/swappers/BebopSwapper/endpoints.js +35 -2
  14. package/dist/cjs/swappers/BebopSwapper/executeSolanaMessage.d.ts +2 -0
  15. package/dist/cjs/swappers/BebopSwapper/executeSolanaMessage.js +47 -0
  16. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.d.ts +4 -0
  17. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +91 -0
  18. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.d.ts +4 -0
  19. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +88 -0
  20. package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +10 -0
  21. package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -0
  22. package/dist/cjs/swappers/BebopSwapper/types.d.ts +49 -1
  23. package/dist/cjs/swappers/BebopSwapper/types.js +9 -2
  24. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +19 -1
  25. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +86 -1
  26. package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +13 -1
  27. package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.js +47 -1
  28. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +17 -1
  29. package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.js +10 -0
  30. package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +10 -0
  31. package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +10 -0
  32. package/dist/cjs/swappers/CetusSwapper/utils/helpers.d.ts +1 -1
  33. package/dist/cjs/swappers/CetusSwapper/utils/helpers.js +1 -1
  34. package/dist/cjs/swappers/ChainflipSwapper/constants.js +7 -3
  35. package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +17 -0
  36. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +10 -0
  37. package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +9 -0
  38. package/dist/cjs/swappers/DebridgeSwapper/DebridgeSwapper.d.ts +2 -0
  39. package/dist/cjs/swappers/DebridgeSwapper/DebridgeSwapper.js +7 -0
  40. package/dist/cjs/swappers/DebridgeSwapper/constant.d.ts +5 -0
  41. package/dist/cjs/swappers/DebridgeSwapper/constant.js +36 -0
  42. package/dist/cjs/swappers/DebridgeSwapper/endpoints.d.ts +2 -0
  43. package/dist/cjs/swappers/DebridgeSwapper/endpoints.js +217 -0
  44. package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
  45. package/dist/cjs/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +31 -0
  46. package/dist/cjs/swappers/DebridgeSwapper/getTradeRate/getTradeRate.d.ts +3 -0
  47. package/dist/cjs/swappers/DebridgeSwapper/getTradeRate/getTradeRate.js +19 -0
  48. package/dist/cjs/swappers/DebridgeSwapper/index.d.ts +1 -0
  49. package/dist/cjs/swappers/DebridgeSwapper/index.js +5 -0
  50. package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.d.ts +5 -0
  51. package/dist/cjs/swappers/DebridgeSwapper/utils/debridgeService.js +17 -0
  52. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.d.ts +16 -0
  53. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.js +23 -0
  54. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +20 -0
  55. package/dist/cjs/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.js +29 -0
  56. package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.d.ts +11 -0
  57. package/dist/cjs/swappers/DebridgeSwapper/utils/getTrade.js +369 -0
  58. package/dist/cjs/swappers/DebridgeSwapper/utils/types.d.ts +155 -0
  59. package/dist/cjs/swappers/DebridgeSwapper/utils/types.js +9 -0
  60. package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +32 -0
  61. package/dist/cjs/swappers/JupiterSwapper/swapperApi/getTradeRate.js +9 -0
  62. package/dist/cjs/swappers/MayachainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +1 -1
  63. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +12 -0
  64. package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +12 -0
  65. package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
  66. package/dist/cjs/swappers/RelaySwapper/constant.js +4 -3
  67. package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +44 -5
  68. package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +17 -7
  69. package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +10 -0
  70. package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.js +10 -0
  71. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +10 -0
  72. package/dist/cjs/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
  73. package/dist/cjs/swappers/ThorchainSwapper/endpoints.js +2 -0
  74. package/dist/cjs/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
  75. package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.d.ts +1 -1
  76. package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +2 -1
  77. package/dist/cjs/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.test.js +10 -0
  78. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +9 -0
  79. package/dist/cjs/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +9 -0
  80. package/dist/cjs/swappers/utils/affiliateFee.d.ts +17 -0
  81. package/dist/cjs/swappers/utils/affiliateFee.js +43 -0
  82. package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +57 -4
  83. package/dist/cjs/thorchain-utils/index.d.ts +2 -1
  84. package/dist/cjs/thorchain-utils/index.js +2 -1
  85. package/dist/cjs/thorchain-utils/solana/constants.d.ts +1 -0
  86. package/dist/cjs/thorchain-utils/solana/constants.js +6 -0
  87. package/dist/cjs/thorchain-utils/solana/getSolanaTransactionFees.d.ts +2 -0
  88. package/dist/cjs/thorchain-utils/solana/getSolanaTransactionFees.js +41 -0
  89. package/dist/cjs/thorchain-utils/solana/getThorTxData.d.ts +12 -0
  90. package/dist/cjs/thorchain-utils/solana/getThorTxData.js +14 -0
  91. package/dist/cjs/thorchain-utils/solana/getUnsignedSolanaTransaction.d.ts +3 -0
  92. package/dist/cjs/thorchain-utils/solana/getUnsignedSolanaTransaction.js +64 -0
  93. package/dist/cjs/thorchain-utils/solana/index.d.ts +3 -0
  94. package/dist/cjs/thorchain-utils/solana/index.js +19 -0
  95. package/dist/cjs/types.d.ts +44 -5
  96. package/dist/cjs/types.js +1 -0
  97. package/dist/esm/.tsbuildinfo +1 -1
  98. package/dist/esm/constants.js +11 -0
  99. package/dist/esm/cowswap-utils/constants.js +3 -0
  100. package/dist/esm/cowswap-utils/index.js +6 -0
  101. package/dist/esm/index.d.ts +1 -0
  102. package/dist/esm/index.js +1 -0
  103. package/dist/esm/swappers/AcrossSwapper/constant.js +4 -2
  104. package/dist/esm/swappers/AcrossSwapper/utils/getTrade.js +15 -1
  105. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +9 -0
  106. package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.js +9 -0
  107. package/dist/esm/swappers/BebopSwapper/BebopSwapper.js +2 -0
  108. package/dist/esm/swappers/BebopSwapper/endpoints.js +36 -3
  109. package/dist/esm/swappers/BebopSwapper/executeSolanaMessage.d.ts +2 -0
  110. package/dist/esm/swappers/BebopSwapper/executeSolanaMessage.js +40 -0
  111. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.d.ts +4 -0
  112. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeQuote/getBebopSolanaTradeQuote.js +87 -0
  113. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.d.ts +4 -0
  114. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +84 -0
  115. package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +10 -0
  116. package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -0
  117. package/dist/esm/swappers/BebopSwapper/types.d.ts +49 -1
  118. package/dist/esm/swappers/BebopSwapper/types.js +8 -1
  119. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +19 -1
  120. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +85 -2
  121. package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +13 -1
  122. package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.js +44 -1
  123. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +17 -1
  124. package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.js +10 -0
  125. package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +10 -0
  126. package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +10 -0
  127. package/dist/esm/swappers/CetusSwapper/utils/helpers.d.ts +1 -1
  128. package/dist/esm/swappers/CetusSwapper/utils/helpers.js +1 -1
  129. package/dist/esm/swappers/ChainflipSwapper/constants.js +8 -4
  130. package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +17 -0
  131. package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +10 -0
  132. package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +9 -0
  133. package/dist/esm/swappers/DebridgeSwapper/DebridgeSwapper.d.ts +2 -0
  134. package/dist/esm/swappers/DebridgeSwapper/DebridgeSwapper.js +4 -0
  135. package/dist/esm/swappers/DebridgeSwapper/constant.d.ts +5 -0
  136. package/dist/esm/swappers/DebridgeSwapper/constant.js +30 -0
  137. package/dist/esm/swappers/DebridgeSwapper/endpoints.d.ts +2 -0
  138. package/dist/esm/swappers/DebridgeSwapper/endpoints.js +211 -0
  139. package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
  140. package/dist/esm/swappers/DebridgeSwapper/getTradeQuote/getTradeQuote.js +27 -0
  141. package/dist/esm/swappers/DebridgeSwapper/getTradeRate/getTradeRate.d.ts +3 -0
  142. package/dist/esm/swappers/DebridgeSwapper/getTradeRate/getTradeRate.js +15 -0
  143. package/dist/esm/swappers/DebridgeSwapper/index.d.ts +1 -0
  144. package/dist/esm/swappers/DebridgeSwapper/index.js +1 -0
  145. package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.d.ts +5 -0
  146. package/dist/esm/swappers/DebridgeSwapper/utils/debridgeService.js +11 -0
  147. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.d.ts +16 -0
  148. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeSingleChainTrade.js +19 -0
  149. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.d.ts +20 -0
  150. package/dist/esm/swappers/DebridgeSwapper/utils/fetchDebridgeTrade.js +25 -0
  151. package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.d.ts +11 -0
  152. package/dist/esm/swappers/DebridgeSwapper/utils/getTrade.js +362 -0
  153. package/dist/esm/swappers/DebridgeSwapper/utils/types.d.ts +155 -0
  154. package/dist/esm/swappers/DebridgeSwapper/utils/types.js +5 -0
  155. package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeQuote.js +33 -1
  156. package/dist/esm/swappers/JupiterSwapper/swapperApi/getTradeRate.js +9 -0
  157. package/dist/esm/swappers/MayachainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +1 -1
  158. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +14 -2
  159. package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +14 -2
  160. package/dist/esm/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.js +10 -0
  161. package/dist/esm/swappers/RelaySwapper/constant.js +6 -5
  162. package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +47 -8
  163. package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +17 -7
  164. package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +10 -0
  165. package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.js +10 -0
  166. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +10 -0
  167. package/dist/esm/swappers/ThorchainSwapper/ThorchainSwapper.js +3 -0
  168. package/dist/esm/swappers/ThorchainSwapper/endpoints.js +3 -1
  169. package/dist/esm/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json +1 -0
  170. package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.d.ts +1 -1
  171. package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.js +2 -1
  172. package/dist/esm/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.test.js +11 -1
  173. package/dist/esm/swappers/ZrxSwapper/getZrxTradeQuote/getZrxTradeQuote.js +9 -0
  174. package/dist/esm/swappers/ZrxSwapper/getZrxTradeRate/getZrxTradeRate.js +9 -0
  175. package/dist/esm/swappers/utils/affiliateFee.d.ts +17 -0
  176. package/dist/esm/swappers/utils/affiliateFee.js +39 -0
  177. package/dist/esm/thorchain-utils/getL1RateOrQuote.js +57 -4
  178. package/dist/esm/thorchain-utils/index.d.ts +2 -1
  179. package/dist/esm/thorchain-utils/index.js +1 -0
  180. package/dist/esm/thorchain-utils/solana/constants.d.ts +1 -0
  181. package/dist/esm/thorchain-utils/solana/constants.js +3 -0
  182. package/dist/esm/thorchain-utils/solana/getSolanaTransactionFees.d.ts +2 -0
  183. package/dist/esm/thorchain-utils/solana/getSolanaTransactionFees.js +37 -0
  184. package/dist/esm/thorchain-utils/solana/getThorTxData.d.ts +12 -0
  185. package/dist/esm/thorchain-utils/solana/getThorTxData.js +10 -0
  186. package/dist/esm/thorchain-utils/solana/getUnsignedSolanaTransaction.d.ts +3 -0
  187. package/dist/esm/thorchain-utils/solana/getUnsignedSolanaTransaction.js +60 -0
  188. package/dist/esm/thorchain-utils/solana/index.d.ts +3 -0
  189. package/dist/esm/thorchain-utils/solana/index.js +3 -0
  190. package/dist/esm/types.d.ts +44 -5
  191. package/dist/esm/types.js +1 -0
  192. package/package.json +19 -18
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSolanaTransactionFees = void 0;
4
+ const utils_1 = require("@shapeshiftoss/utils");
5
+ const web3_js_1 = require("@solana/web3.js");
6
+ const utils_2 = require("../../utils");
7
+ const getThorTxData_1 = require("./getThorTxData");
8
+ const MEMO_PROGRAM_ID = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
9
+ const getSolanaTransactionFees = async (args, swapperName) => {
10
+ const { tradeQuote, stepIndex, from, assertGetSolanaChainAdapter, config } = args;
11
+ if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
12
+ throw new Error('Unable to execute a trade rate quote');
13
+ const { memo } = tradeQuote;
14
+ if (!memo)
15
+ throw new Error('Memo is required');
16
+ const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
17
+ const { sellAmountIncludingProtocolFeesCryptoBaseUnit, sellAsset } = step;
18
+ const { vault } = await (0, getThorTxData_1.getThorTxData)({ sellAsset, config, swapperName });
19
+ const adapter = assertGetSolanaChainAdapter(sellAsset.chainId);
20
+ const memoInstruction = new web3_js_1.TransactionInstruction({
21
+ keys: [],
22
+ programId: new web3_js_1.PublicKey(MEMO_PROGRAM_ID),
23
+ data: Buffer.from(memo, 'utf8'),
24
+ });
25
+ const transferInstruction = web3_js_1.SystemProgram.transfer({
26
+ fromPubkey: new web3_js_1.PublicKey(from),
27
+ toPubkey: new web3_js_1.PublicKey(vault),
28
+ lamports: BigInt(sellAmountIncludingProtocolFeesCryptoBaseUnit),
29
+ });
30
+ const { fast } = await adapter.getFeeData({
31
+ to: vault,
32
+ value: '0',
33
+ chainSpecific: {
34
+ from,
35
+ tokenId: (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId),
36
+ instructions: [memoInstruction, transferInstruction],
37
+ },
38
+ });
39
+ return fast.txFee;
40
+ };
41
+ exports.getSolanaTransactionFees = getSolanaTransactionFees;
@@ -0,0 +1,12 @@
1
+ import type { Asset } from '@shapeshiftoss/types';
2
+ import type { SwapperConfig, SwapperName } from '../../types';
3
+ type GetThorTxDataArgs = {
4
+ sellAsset: Asset;
5
+ config: SwapperConfig;
6
+ swapperName: SwapperName;
7
+ };
8
+ type GetThorTxDataReturn = {
9
+ vault: string;
10
+ };
11
+ export declare const getThorTxData: ({ sellAsset, config, swapperName, }: GetThorTxDataArgs) => Promise<GetThorTxDataReturn>;
12
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getThorTxData = void 0;
4
+ const getInboundAddressDataForChain_1 = require("../getInboundAddressDataForChain");
5
+ const index_1 = require("../index");
6
+ const getThorTxData = async ({ sellAsset, config, swapperName, }) => {
7
+ const daemonUrl = (0, index_1.getDaemonUrl)(config, swapperName);
8
+ const res = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(daemonUrl, sellAsset.assetId, false, swapperName);
9
+ if (res.isErr())
10
+ throw res.unwrapErr();
11
+ const { address: vault } = res.unwrap();
12
+ return { vault };
13
+ };
14
+ exports.getThorTxData = getThorTxData;
@@ -0,0 +1,3 @@
1
+ import type { SolanaSignTx } from '@shapeshiftoss/hdwallet-core';
2
+ import type { GetUnsignedSolanaTransactionArgs, SwapperName } from '../../types';
3
+ export declare const getUnsignedSolanaTransaction: (args: GetUnsignedSolanaTransactionArgs, swapperName: SwapperName) => Promise<SolanaSignTx>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUnsignedSolanaTransaction = void 0;
4
+ const utils_1 = require("@shapeshiftoss/utils");
5
+ const web3_js_1 = require("@solana/web3.js");
6
+ const utils_2 = require("../../utils");
7
+ const getThorTxData_1 = require("./getThorTxData");
8
+ const MEMO_PROGRAM_ID = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
9
+ // Each ComputeBudgetProgram instruction (setComputeUnitLimit, setComputeUnitPrice) costs 150 CU.
10
+ // Fee estimation doesn't include these, so we add a fixed buffer to cover them.
11
+ const COMPUTE_BUDGET_INSTRUCTION_OVERHEAD_CU = 300;
12
+ const getUnsignedSolanaTransaction = async (args, swapperName) => {
13
+ const { tradeQuote, stepIndex, from, assertGetSolanaChainAdapter, config } = args;
14
+ if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
15
+ throw new Error('Unable to execute a trade rate quote');
16
+ const { memo } = tradeQuote;
17
+ if (!memo)
18
+ throw new Error('Memo is required');
19
+ const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
20
+ const { accountNumber, sellAmountIncludingProtocolFeesCryptoBaseUnit, sellAsset } = step;
21
+ const { vault } = await (0, getThorTxData_1.getThorTxData)({
22
+ sellAsset,
23
+ config,
24
+ swapperName,
25
+ });
26
+ const adapter = assertGetSolanaChainAdapter(sellAsset.chainId);
27
+ const memoInstruction = new web3_js_1.TransactionInstruction({
28
+ keys: [],
29
+ programId: new web3_js_1.PublicKey(MEMO_PROGRAM_ID),
30
+ data: Buffer.from(memo, 'utf8'),
31
+ });
32
+ const transferInstruction = web3_js_1.SystemProgram.transfer({
33
+ fromPubkey: new web3_js_1.PublicKey(from),
34
+ toPubkey: new web3_js_1.PublicKey(vault),
35
+ lamports: BigInt(sellAmountIncludingProtocolFeesCryptoBaseUnit),
36
+ });
37
+ const { fast } = await adapter.getFeeData({
38
+ to: vault,
39
+ value: '0',
40
+ chainSpecific: {
41
+ from,
42
+ tokenId: (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId),
43
+ instructions: [memoInstruction, transferInstruction],
44
+ },
45
+ });
46
+ const memoHdwalletInstruction = {
47
+ keys: [],
48
+ programId: MEMO_PROGRAM_ID,
49
+ data: Buffer.from(memo, 'utf8'),
50
+ };
51
+ return adapter.buildSendApiTransaction({
52
+ from,
53
+ to: vault,
54
+ value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
55
+ accountNumber,
56
+ chainSpecific: {
57
+ instructions: [memoHdwalletInstruction],
58
+ computeUnitLimit: String(Number(fast.chainSpecific.computeUnits) + COMPUTE_BUDGET_INSTRUCTION_OVERHEAD_CU),
59
+ computeUnitPrice: fast.chainSpecific.priorityFee,
60
+ tokenId: (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId),
61
+ },
62
+ });
63
+ };
64
+ exports.getUnsignedSolanaTransaction = getUnsignedSolanaTransaction;
@@ -0,0 +1,3 @@
1
+ export * from './getThorTxData';
2
+ export * from './getUnsignedSolanaTransaction';
3
+ export * from './getSolanaTransactionFees';
@@ -0,0 +1,19 @@
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
+ __exportStar(require("./getThorTxData"), exports);
18
+ __exportStar(require("./getUnsignedSolanaTransaction"), exports);
19
+ __exportStar(require("./getSolanaTransactionFees"), exports);
@@ -2,7 +2,7 @@ import type { QuoteResponse } from '@jup-ag/api';
2
2
  import type { AccountId, AssetId, ChainId, Nominal } from '@shapeshiftoss/caip';
3
3
  import type { ChainAdapter, CosmosSdkChainAdapter, EvmChainAdapter, near, SignTx, solana, starknet, sui, ton, tron, UtxoChainAdapter } from '@shapeshiftoss/chain-adapters';
4
4
  import type { HDWallet, SolanaSignTx, StarknetSignTx, SuiSignTx } from '@shapeshiftoss/hdwallet-core';
5
- import type { AccountMetadata, Asset, AssetsByIdPartial, CosmosSdkChainId, EvmChainId, KnownChainIds, NearChainId, OrderQuoteResponse, PartialRecord, TonChainId, TronChainId, UtxoAccountType, UtxoChainId } from '@shapeshiftoss/types';
5
+ import type { AccountMetadata, Asset, AssetsByIdPartial, CosmosSdkChainId, EvmChainId, KnownChainIds, NearChainId, OrderQuoteResponse, PartialRecord, SolanaChainId, TonChainId, TronChainId, UtxoAccountType, UtxoChainId } from '@shapeshiftoss/types';
6
6
  import type { TxStatus } from '@shapeshiftoss/unchained-client';
7
7
  import type { Result } from '@sniptt/monads';
8
8
  import type { TransactionInstruction } from '@solana/web3.js';
@@ -13,6 +13,7 @@ import type { InterpolationOptions } from 'node-polyglot';
13
13
  import type { Address, Hex } from 'viem';
14
14
  import type { AcrossTransactionMetadata } from './swappers/AcrossSwapper/utils/types';
15
15
  import type { CowMessageToSign } from './swappers/CowSwapper/types';
16
+ import type { DebridgeTransactionMetadata } from './swappers/DebridgeSwapper/utils/types';
16
17
  import type { RelayTransactionMetadata } from './swappers/RelaySwapper/utils/types';
17
18
  import type { makeSwapperAxiosServiceMonadic } from './utils';
18
19
  export type SwapperConfig = {
@@ -50,6 +51,7 @@ export type SwapperConfig = {
50
51
  VITE_SUI_NODE_URL: string;
51
52
  VITE_ACROSS_API_URL: string;
52
53
  VITE_ACROSS_INTEGRATOR_ID: string;
54
+ VITE_DEBRIDGE_API_URL: string;
53
55
  };
54
56
  export declare enum SwapperName {
55
57
  Thorchain = "THORChain",
@@ -69,7 +71,8 @@ export declare enum SwapperName {
69
71
  Sunio = "Sun.io",
70
72
  Avnu = "AVNU",
71
73
  Stonfi = "STON.fi",
72
- Across = "Across"
74
+ Across = "Across",
75
+ Debridge = "deBridge"
73
76
  }
74
77
  export type SwapSource = SwapperName | `${SwapperName} • ${string}`;
75
78
  export type SwapErrorRight = {
@@ -133,6 +136,7 @@ type CommonTradeInputBase = {
133
136
  buyAsset: Asset;
134
137
  sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
135
138
  affiliateBps: string;
139
+ affiliateAddress?: string;
136
140
  allowMultiHop: boolean;
137
141
  slippageTolerancePercentageDecimal?: string;
138
142
  };
@@ -197,6 +201,15 @@ export type GetTonTradeQuoteInput = CommonTradeInput & {
197
201
  export type GetTonTradeRateInput = CommonTradeRateInput & {
198
202
  chainId: TonChainId;
199
203
  };
204
+ export type GetSolanaTradeQuoteInputBase = CommonTradeInput & {
205
+ chainId: SolanaChainId;
206
+ };
207
+ export type GetSolanaTradeQuoteInput = CommonTradeInput & {
208
+ chainId: SolanaChainId;
209
+ };
210
+ export type GetSolanaTradeRateInput = CommonTradeRateInput & {
211
+ chainId: SolanaChainId;
212
+ };
200
213
  type GetUtxoTradeQuoteWithWallet = CommonTradeQuoteInput & {
201
214
  chainId: UtxoChainId;
202
215
  accountType: UtxoAccountType;
@@ -210,9 +223,9 @@ export type GetUtxoTradeRateInput = CommonTradeRateInput & {
210
223
  xpub: string | undefined;
211
224
  };
212
225
  export type GetUtxoTradeQuoteInput = GetUtxoTradeQuoteWithWallet;
213
- export type GetTradeQuoteInput = GetUtxoTradeQuoteInput | GetEvmTradeQuoteInput | GetCosmosSdkTradeQuoteInput | GetTronTradeQuoteInput | GetNearTradeQuoteInput | GetTonTradeQuoteInput;
214
- export type GetTradeRateInput = GetEvmTradeRateInput | GetCosmosSdkTradeRateInput | GetUtxoTradeRateInput | GetTronTradeRateInput | GetNearTradeRateInput | GetTonTradeRateInput;
215
- export type GetTradeQuoteInputWithWallet = GetUtxoTradeQuoteWithWallet | GetEvmTradeQuoteInputBase | GetCosmosSdkTradeQuoteInputBase | GetTronTradeQuoteInputBase | GetNearTradeQuoteInputBase | GetTonTradeQuoteInputBase;
226
+ export type GetTradeQuoteInput = GetUtxoTradeQuoteInput | GetEvmTradeQuoteInput | GetCosmosSdkTradeQuoteInput | GetTronTradeQuoteInput | GetNearTradeQuoteInput | GetTonTradeQuoteInput | GetSolanaTradeQuoteInput;
227
+ export type GetTradeRateInput = GetEvmTradeRateInput | GetCosmosSdkTradeRateInput | GetUtxoTradeRateInput | GetTronTradeRateInput | GetNearTradeRateInput | GetTonTradeRateInput | GetSolanaTradeRateInput;
228
+ export type GetTradeQuoteInputWithWallet = GetUtxoTradeQuoteWithWallet | GetEvmTradeQuoteInputBase | GetCosmosSdkTradeQuoteInputBase | GetTronTradeQuoteInputBase | GetNearTradeQuoteInputBase | GetTonTradeQuoteInputBase | GetSolanaTradeQuoteInputBase;
216
229
  export type EvmSwapperDeps = {
217
230
  assertGetEvmChainAdapter: (chainId: ChainId) => EvmChainAdapter;
218
231
  fetchIsSmartContractAddressQuery: (userAddress: string, chainId: ChainId) => Promise<boolean>;
@@ -247,6 +260,12 @@ export type SwapperDeps = {
247
260
  mixPanel: Mixpanel | undefined;
248
261
  assertGetChainAdapter: (chainId: ChainId) => ChainAdapter<KnownChainIds>;
249
262
  } & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & TronSwapperDeps & SuiSwapperDeps & NearSwapperDeps & StarknetSwapperDeps & TonSwapperDeps;
263
+ export type AffiliateFee = {
264
+ assetId: AssetId;
265
+ amountCryptoBaseUnit: string;
266
+ asset: Asset;
267
+ isEstimate?: boolean;
268
+ };
250
269
  export type TradeQuoteStep = {
251
270
  buyAmountBeforeFeesCryptoBaseUnit: string;
252
271
  buyAmountAfterFeesCryptoBaseUnit: string;
@@ -286,10 +305,14 @@ export type TradeQuoteStep = {
286
305
  value: Hex;
287
306
  gas?: string;
288
307
  };
308
+ bebopSolanaSerializedTx?: string;
309
+ bebopQuoteId?: string;
289
310
  jupiterQuoteResponse?: QuoteResponse;
290
311
  solanaTransactionMetadata?: {
291
312
  addressLookupTableAddresses: string[];
292
313
  instructions?: TransactionInstruction[];
314
+ /** True when the serialized tx exceeds the 1232-byte Solana limit and needs Jito bundle splitting */
315
+ isOversized?: boolean;
293
316
  };
294
317
  cowswapQuoteResponse?: OrderQuoteResponse;
295
318
  chainflipSpecific?: {
@@ -376,6 +399,8 @@ export type TradeQuoteStep = {
376
399
  params?: unknown;
377
400
  };
378
401
  acrossTransactionMetadata?: AcrossTransactionMetadata;
402
+ debridgeTransactionMetadata?: DebridgeTransactionMetadata;
403
+ affiliateFee?: AffiliateFee;
379
404
  };
380
405
  export type TradeRateStep = Omit<TradeQuoteStep, 'accountNumber'> & {
381
406
  accountNumber: undefined;
@@ -430,6 +455,7 @@ export type SwapperSpecificMetadata = {
430
455
  };
431
456
  relayTransactionMetadata: RelayTransactionMetadata | undefined;
432
457
  acrossTransactionMetadata: AcrossTransactionMetadata | undefined;
458
+ debridgeTransactionMetadata: DebridgeTransactionMetadata | undefined;
433
459
  relayerExplorerTxLink: string | undefined;
434
460
  relayerTxHash: string | undefined;
435
461
  stepIndex: SupportedTradeQuoteStepIndex;
@@ -522,6 +548,15 @@ export type CosmosSdkTransactionExecutionProps = {
522
548
  };
523
549
  export type SolanaTransactionExecutionProps = {
524
550
  signAndBroadcastTransaction: (txToSign: SolanaSignTx) => Promise<string>;
551
+ /** Sign-only callback for Jito bundle flow (sign without broadcasting) */
552
+ signTransaction?: (txToSign: SolanaSignTx) => Promise<string>;
553
+ };
554
+ export type SolanaMessageToSign = {
555
+ serializedTx: string;
556
+ quoteId: string;
557
+ };
558
+ export type SolanaMessageExecutionProps = {
559
+ signSerializedTransaction: (serializedTx: string) => Promise<string[]>;
525
560
  };
526
561
  export type TronTransactionExecutionProps = {
527
562
  signAndBroadcastTransaction: (txToSign: tron.TronSignTx) => Promise<string>;
@@ -585,6 +620,7 @@ type TonAccountMetadata = {
585
620
  };
586
621
  export type GetUnsignedTonTransactionArgs = CommonGetUnsignedTransactionArgs & TonAccountMetadata & TonSwapperDeps;
587
622
  export type GetUnsignedEvmMessageArgs = CommonGetUnsignedTransactionArgs & EvmAccountMetadata & Omit<EvmSwapperDeps, 'fetchIsSmartContractAddressQuery'>;
623
+ export type GetUnsignedSolanaMessageArgs = CommonGetUnsignedTransactionArgs;
588
624
  export type GetUnsignedUtxoTransactionArgs = CommonGetUnsignedTransactionArgs & UtxoAccountMetadata & UtxoSwapperDeps;
589
625
  export type GetUnsignedCosmosSdkTransactionArgs = CommonGetUnsignedTransactionArgs & CosmosSdkAccountMetadata & CosmosSdkSwapperDeps;
590
626
  export type UnsignedTx = Nominal<Record<string, any>, 'UnsignedTx'>;
@@ -621,6 +657,7 @@ export type Swapper = {
621
657
  executeUtxoTransaction?: (txToSign: SignTx<UtxoChainId>, callbacks: UtxoTransactionExecutionProps) => Promise<string>;
622
658
  executeCosmosSdkTransaction?: (txToSign: SignTx<CosmosSdkChainId>, callbacks: CosmosSdkTransactionExecutionProps) => Promise<string>;
623
659
  executeSolanaTransaction?: (txToSign: SolanaSignTx, callbacks: SolanaTransactionExecutionProps) => Promise<string>;
660
+ executeSolanaMessage?: (messageData: SolanaMessageToSign, callbacks: SolanaMessageExecutionProps, config: SwapperConfig) => Promise<string>;
624
661
  executeTronTransaction?: (txToSign: tron.TronSignTx, callbacks: TronTransactionExecutionProps) => Promise<string>;
625
662
  executeSuiTransaction?: (txToSign: SuiSignTx, callbacks: SuiTransactionExecutionProps) => Promise<string>;
626
663
  executeNearTransaction?: (txToSign: near.NearSignTx, callbacks: NearTransactionExecutionProps) => Promise<string>;
@@ -637,6 +674,7 @@ export type SwapperApi = {
637
674
  getUnsignedUtxoTransaction?: (input: GetUnsignedUtxoTransactionArgs) => Promise<SignTx<UtxoChainId>>;
638
675
  getUnsignedCosmosSdkTransaction?: (input: GetUnsignedCosmosSdkTransactionArgs) => Promise<SignTx<CosmosSdkChainId>>;
639
676
  getUnsignedSolanaTransaction?: (input: GetUnsignedSolanaTransactionArgs) => Promise<SolanaSignTx>;
677
+ getUnsignedSolanaMessage?: (input: GetUnsignedSolanaMessageArgs) => Promise<SolanaMessageToSign>;
640
678
  getUnsignedTronTransaction?: (input: GetUnsignedTronTransactionArgs) => Promise<tron.TronSignTx>;
641
679
  getUnsignedSuiTransaction?: (input: GetUnsignedSuiTransactionArgs) => Promise<SuiSignTx>;
642
680
  getUnsignedNearTransaction?: (input: GetUnsignedNearTransactionArgs) => Promise<near.NearSignTx>;
@@ -673,6 +711,7 @@ export type EvmMessageExecutionInput = CommonTradeExecutionInput & EvmMessageExe
673
711
  export type UtxoTransactionExecutionInput = CommonTradeExecutionInput & UtxoTransactionExecutionProps & UtxoAccountMetadata;
674
712
  export type CosmosSdkTransactionExecutionInput = CommonTradeExecutionInput & CosmosSdkTransactionExecutionProps & CosmosSdkAccountMetadata;
675
713
  export type SolanaTransactionExecutionInput = CommonTradeExecutionInput & SolanaTransactionExecutionProps & SolanaAccountMetadata;
714
+ export type SolanaMessageExecutionInput = CommonTradeExecutionInput & SolanaMessageExecutionProps;
676
715
  export type TronTransactionExecutionInput = CommonTradeExecutionInput & TronTransactionExecutionProps & TronAccountMetadata;
677
716
  export type SuiTransactionExecutionInput = CommonTradeExecutionInput & SuiTransactionExecutionProps & SuiAccountMetadata;
678
717
  export type NearTransactionExecutionInput = CommonTradeExecutionInput & NearTransactionExecutionProps & NearAccountMetadata;
package/dist/cjs/types.js CHANGED
@@ -21,6 +21,7 @@ var SwapperName;
21
21
  SwapperName["Avnu"] = "AVNU";
22
22
  SwapperName["Stonfi"] = "STON.fi";
23
23
  SwapperName["Across"] = "Across";
24
+ SwapperName["Debridge"] = "deBridge";
24
25
  })(SwapperName || (exports.SwapperName = SwapperName = {}));
25
26
  var TradeQuoteError;
26
27
  (function (TradeQuoteError) {