@shapeshiftoss/swapper 17.7.3 → 17.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/constants.js +35 -26
  3. package/dist/cjs/index.d.ts +1 -0
  4. package/dist/cjs/index.js +1 -0
  5. package/dist/cjs/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
  6. package/dist/cjs/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +9 -5
  7. package/dist/cjs/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +1 -9
  8. package/dist/cjs/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +9 -13
  9. package/dist/cjs/swappers/BebopSwapper/types.d.ts +64 -78
  10. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +0 -16
  11. package/dist/cjs/swappers/BebopSwapper/utils/fetchFromBebop.js +49 -82
  12. package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
  13. package/dist/cjs/swappers/BobGatewaySwapper/BobGatewaySwapper.js +8 -0
  14. package/dist/cjs/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
  15. package/dist/cjs/swappers/BobGatewaySwapper/endpoints.js +143 -0
  16. package/dist/cjs/swappers/BobGatewaySwapper/index.d.ts +3 -0
  17. package/dist/cjs/swappers/BobGatewaySwapper/index.js +22 -0
  18. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
  19. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +90 -0
  20. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
  21. package/dist/cjs/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +73 -0
  22. package/dist/cjs/swappers/BobGatewaySwapper/types.d.ts +20 -0
  23. package/dist/cjs/swappers/BobGatewaySwapper/types.js +2 -0
  24. package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
  25. package/dist/cjs/swappers/BobGatewaySwapper/utils/constants.js +31 -0
  26. package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
  27. package/dist/cjs/swappers/BobGatewaySwapper/utils/helpers.js +314 -0
  28. package/dist/cjs/swappers/ChainflipSwapper/ChainflipSwapper.js +1 -0
  29. package/dist/cjs/swappers/ChainflipSwapper/constants.d.ts +1 -1
  30. package/dist/cjs/swappers/ChainflipSwapper/constants.js +3 -0
  31. package/dist/cjs/swappers/ChainflipSwapper/endpoints.js +20 -0
  32. package/dist/cjs/swappers/ChainflipSwapper/types.d.ts +2 -1
  33. package/dist/cjs/swappers/ChainflipSwapper/types.js +1 -0
  34. package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +23 -3
  35. package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -2
  36. package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.js +2 -1
  37. package/dist/cjs/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
  38. package/dist/cjs/swappers/RelaySwapper/constant.js +1 -1
  39. package/dist/cjs/swappers/SunioSwapper/endpoints.js +19 -36
  40. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
  41. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapContractCall.js +33 -0
  42. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
  43. package/dist/cjs/swappers/SunioSwapper/utils/constants.d.ts +2 -0
  44. package/dist/cjs/swappers/SunioSwapper/utils/constants.js +7 -1
  45. package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
  46. package/dist/cjs/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +78 -0
  47. package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +16 -74
  48. package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
  49. package/dist/cjs/swappers/SunioSwapper/utils/getSunioTransactionFees.js +36 -0
  50. package/dist/cjs/swappers/utils/helpers/helpers.js +1 -0
  51. package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +5 -2
  52. package/dist/cjs/thorchain-utils/getQuote.js +27 -29
  53. package/dist/cjs/thorchain-utils/tron/getTronTransactionFees.js +8 -5
  54. package/dist/cjs/thorchain-utils/types.d.ts +1 -1
  55. package/dist/cjs/types.d.ts +10 -3
  56. package/dist/cjs/types.js +5 -0
  57. package/dist/esm/.tsbuildinfo +1 -1
  58. package/dist/esm/constants.js +9 -0
  59. package/dist/esm/index.d.ts +1 -0
  60. package/dist/esm/index.js +1 -0
  61. package/dist/esm/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote.test.js +12 -4
  62. package/dist/esm/swappers/BebopSwapper/getBebopSolanaTradeRate/getBebopSolanaTradeRate.js +10 -6
  63. package/dist/esm/swappers/BebopSwapper/getBebopTradeQuote/getBebopTradeQuote.js +1 -9
  64. package/dist/esm/swappers/BebopSwapper/getBebopTradeRate/getBebopTradeRate.js +10 -14
  65. package/dist/esm/swappers/BebopSwapper/types.d.ts +64 -78
  66. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.d.ts +0 -16
  67. package/dist/esm/swappers/BebopSwapper/utils/fetchFromBebop.js +45 -76
  68. package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.d.ts +2 -0
  69. package/dist/esm/swappers/BobGatewaySwapper/BobGatewaySwapper.js +5 -0
  70. package/dist/esm/swappers/BobGatewaySwapper/endpoints.d.ts +2 -0
  71. package/dist/esm/swappers/BobGatewaySwapper/endpoints.js +140 -0
  72. package/dist/esm/swappers/BobGatewaySwapper/index.d.ts +3 -0
  73. package/dist/esm/swappers/BobGatewaySwapper/index.js +3 -0
  74. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.d.ts +3 -0
  75. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeQuote.js +86 -0
  76. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.d.ts +3 -0
  77. package/dist/esm/swappers/BobGatewaySwapper/swapperApi/getTradeRate.js +69 -0
  78. package/dist/esm/swappers/BobGatewaySwapper/types.d.ts +20 -0
  79. package/dist/esm/swappers/BobGatewaySwapper/utils/constants.d.ts +13 -0
  80. package/dist/esm/swappers/BobGatewaySwapper/utils/constants.js +27 -0
  81. package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.d.ts +49 -0
  82. package/dist/esm/swappers/BobGatewaySwapper/utils/helpers.js +299 -0
  83. package/dist/esm/swappers/ChainflipSwapper/ChainflipSwapper.js +2 -1
  84. package/dist/esm/swappers/ChainflipSwapper/constants.d.ts +1 -1
  85. package/dist/esm/swappers/ChainflipSwapper/constants.js +4 -1
  86. package/dist/esm/swappers/ChainflipSwapper/endpoints.js +20 -0
  87. package/dist/esm/swappers/ChainflipSwapper/types.d.ts +2 -1
  88. package/dist/esm/swappers/ChainflipSwapper/types.js +1 -0
  89. package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +24 -4
  90. package/dist/esm/swappers/ChainflipSwapper/utils/helpers.d.ts +2 -2
  91. package/dist/esm/swappers/ChainflipSwapper/utils/helpers.js +2 -1
  92. package/dist/esm/swappers/CowSwapper/utils/helpers/helpers.test.js +3 -3
  93. package/dist/esm/swappers/RelaySwapper/constant.js +1 -1
  94. package/dist/esm/swappers/SunioSwapper/endpoints.js +19 -36
  95. package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.d.ts +6 -0
  96. package/dist/esm/swappers/SunioSwapper/utils/buildSwapContractCall.js +29 -0
  97. package/dist/esm/swappers/SunioSwapper/utils/buildSwapRouteParameters.js +6 -6
  98. package/dist/esm/swappers/SunioSwapper/utils/constants.d.ts +2 -0
  99. package/dist/esm/swappers/SunioSwapper/utils/constants.js +6 -0
  100. package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.d.ts +12 -0
  101. package/dist/esm/swappers/SunioSwapper/utils/estimateSunioNetworkFee.js +74 -0
  102. package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +16 -74
  103. package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.d.ts +2 -0
  104. package/dist/esm/swappers/SunioSwapper/utils/getSunioTransactionFees.js +32 -0
  105. package/dist/esm/swappers/utils/helpers/helpers.js +2 -1
  106. package/dist/esm/thorchain-utils/getL1RateOrQuote.js +5 -2
  107. package/dist/esm/thorchain-utils/getQuote.js +27 -29
  108. package/dist/esm/thorchain-utils/tron/getTronTransactionFees.js +8 -5
  109. package/dist/esm/thorchain-utils/types.d.ts +1 -1
  110. package/dist/esm/types.d.ts +10 -3
  111. package/dist/esm/types.js +5 -0
  112. package/package.json +8 -7
  113. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
  114. package/dist/cjs/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -57
  115. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -12
  116. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -47
  117. package/dist/cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -100
  118. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.d.ts +0 -11
  119. package/dist/esm/swappers/SunioSwapper/utils/buildSwapTransaction.js +0 -53
  120. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.d.ts +0 -12
  121. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.js +0 -41
  122. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts +0 -1
  123. package/dist/esm/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.js +0 -98
  124. /package/dist/{cjs/thorchain-utils/getThresholdedAffiliateBps/getThresholdedAffiliateBps.test.d.ts → esm/swappers/BobGatewaySwapper/types.js} +0 -0
@@ -1,30 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchBebopSolanaPrice = exports.fetchBebopSolanaQuote = exports.fetchBebopPrice = exports.fetchBebopQuote = void 0;
3
+ exports.fetchBebopSolanaQuote = exports.fetchBebopQuote = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
4
5
  const utils_1 = require("@shapeshiftoss/utils");
5
6
  const monads_1 = require("@sniptt/monads");
6
7
  const viem_1 = require("viem");
7
8
  const types_1 = require("../../../types");
8
9
  const utils_2 = require("../../../utils");
10
+ const helpers_1 = require("../../utils/helpers/helpers");
9
11
  const types_2 = require("../types");
10
12
  const bebopService_1 = require("./bebopService");
11
- const helpers_1 = require("./helpers/helpers");
13
+ const helpers_2 = require("./helpers/helpers");
12
14
  const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
13
15
  try {
14
- const sellToken = (0, helpers_1.assetIdToBebopToken)(sellAsset.assetId);
15
- const buyToken = (0, helpers_1.assetIdToBebopToken)(buyAsset.assetId);
16
+ const sellToken = (0, helpers_2.assetIdToBebopToken)(sellAsset.assetId);
17
+ const buyToken = (0, helpers_2.assetIdToBebopToken)(buyAsset.assetId);
16
18
  const checksummedTakerAddress = (0, viem_1.getAddress)(takerAddress);
17
19
  const checksummedReceiverAddress = (0, viem_1.getAddress)(receiverAddress);
18
20
  const chainName = types_2.chainIdToBebopChain[sellAsset.chainId];
19
21
  const sellAmountFormatted = (0, utils_1.bn)(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
20
- // Bebop API expects slippage as percentage (not basis points like other APIs)
21
- // e.g. 0.3% → send as 0.3, not 30
22
- // See: https://api.bebop.xyz/pmm/ethereum/docs#/v3/quote_v3_quote_get
23
- const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal ?? 0.003)
24
- .times(100)
25
- .toNumber();
26
- const url = `https://api.bebop.xyz/router/${chainName}/v1/quote`;
27
- const params = new URLSearchParams({
22
+ const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal).times(100).toNumber();
23
+ const baseParams = {
28
24
  sell_tokens: sellToken,
29
25
  buy_tokens: buyToken,
30
26
  sell_amounts: sellAmountFormatted,
@@ -35,38 +31,46 @@ const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtoco
35
31
  skip_validation: 'true',
36
32
  gasless: 'false',
37
33
  source: 'shapeshift',
38
- });
34
+ };
35
+ const jamParams = new URLSearchParams(baseParams);
36
+ const pmmParams = new URLSearchParams(baseParams);
39
37
  if (affiliateBps && affiliateBps !== '0') {
40
- params.set('fee', affiliateBps);
38
+ // JAM collects the fee on-chain and requires a recipient
39
+ jamParams.set('fee', affiliateBps);
40
+ jamParams.set('fee_recipient', (0, viem_1.getAddress)((0, helpers_1.getTreasuryAddressFromChainId)(buyAsset.chainId)));
41
+ // PMM attributes the fee off-chain via source
42
+ pmmParams.set('fee', affiliateBps);
41
43
  }
42
- const bebopService = (0, bebopService_1.bebopServiceFactory)({ apiKey });
43
- const maybeResponse = await bebopService.get(`${url}?${params}`);
44
- if (maybeResponse.isErr()) {
44
+ const service = (0, bebopService_1.bebopServiceFactory)({ apiKey });
45
+ const [maybeJam, maybePmm] = await Promise.all([
46
+ service.get(`https://api.bebop.xyz/jam/${chainName}/v2/quote`, {
47
+ params: jamParams,
48
+ }),
49
+ service.get(`https://api.bebop.xyz/pmm/${chainName}/v3/quote`, {
50
+ params: pmmParams,
51
+ }),
52
+ ]);
53
+ const maybeResponses = [maybeJam, maybePmm];
54
+ if (maybeResponses.every(maybeResponse => maybeResponse.isErr())) {
45
55
  return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
46
56
  message: 'Failed to fetch quote from Bebop',
47
- cause: maybeResponse.unwrapErr().cause,
57
+ cause: maybeResponses[0].unwrapErr().cause,
48
58
  code: types_1.TradeQuoteError.QueryFailed,
49
59
  }));
50
60
  }
51
- const response = maybeResponse.unwrap();
52
- // Log partial route failures for debugging (these are normal and don't indicate quote failure)
53
- if (response.data.errors && Object.keys(response.data.errors).length > 0) {
54
- console.debug('[Bebop] Some routes failed (this is normal):', response.data.errors);
55
- }
56
- // Validate response has routes - only fail if there are NO valid routes
57
- if (!response.data.routes || response.data.routes.length === 0) {
61
+ const quotes = maybeResponses
62
+ .filter(maybeResponse => maybeResponse.isOk())
63
+ .map(maybeResponse => maybeResponse.unwrap().data)
64
+ .filter(quote => Boolean(quote.tx?.data));
65
+ if (!quotes.length) {
58
66
  return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
59
- message: 'No routes available',
67
+ message: 'No route available',
60
68
  code: types_1.TradeQuoteError.NoRouteFound,
61
69
  }));
62
70
  }
63
- if (!response.data.bestPrice) {
64
- return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
65
- message: 'No best price route specified',
66
- code: types_1.TradeQuoteError.InvalidResponse,
67
- }));
68
- }
69
- return (0, monads_1.Ok)(response.data);
71
+ const getBuyAmount = (quote) => (0, utils_1.bnOrZero)(Object.values(quote.buyTokens)[0]?.amount);
72
+ const bestQuote = quotes.reduce((best, quote) => getBuyAmount(quote).gt(getBuyAmount(best)) ? quote : best);
73
+ return (0, monads_1.Ok)(bestQuote);
70
74
  }
71
75
  catch (error) {
72
76
  return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
@@ -77,29 +81,20 @@ const fetchBebopQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtoco
77
81
  }
78
82
  };
79
83
  exports.fetchBebopQuote = fetchBebopQuote;
80
- const fetchBebopPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
81
- const address = receiveAddress || types_2.BEBOP_DUMMY_ADDRESS;
82
- return (0, exports.fetchBebopQuote)({
83
- buyAsset,
84
- sellAsset,
85
- sellAmountIncludingProtocolFeesCryptoBaseUnit,
86
- takerAddress: address,
87
- receiverAddress: address,
88
- slippageTolerancePercentageDecimal: '0.01',
89
- affiliateBps,
90
- apiKey,
91
- });
92
- };
93
- exports.fetchBebopPrice = fetchBebopPrice;
94
84
  const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, takerAddress, receiverAddress, slippageTolerancePercentageDecimal, affiliateBps, apiKey, }) => {
95
85
  try {
96
- const sellToken = (0, helpers_1.assetIdToBebopSolanaToken)(sellAsset.assetId);
97
- const buyToken = (0, helpers_1.assetIdToBebopSolanaToken)(buyAsset.assetId);
86
+ // Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
87
+ // always fails on-chain. Reject up front instead of returning an unexecutable quote.
88
+ if (sellAsset.assetId === caip_1.solAssetId) {
89
+ return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
90
+ message: 'Bebop Solana cannot sell native SOL',
91
+ code: types_1.TradeQuoteError.NoRouteFound,
92
+ }));
93
+ }
94
+ const sellToken = (0, helpers_2.assetIdToBebopSolanaToken)(sellAsset.assetId);
95
+ const buyToken = (0, helpers_2.assetIdToBebopSolanaToken)(buyAsset.assetId);
98
96
  const sellAmountFormatted = (0, utils_1.bn)(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0);
99
- const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal ?? 0.003)
100
- .times(100)
101
- .toNumber();
102
- const url = 'https://api.bebop.xyz/pmm/solana/v3/quote';
97
+ const slippagePercentage = (0, utils_1.bn)(slippageTolerancePercentageDecimal).times(100).toNumber();
103
98
  const params = new URLSearchParams({
104
99
  sell_tokens: sellToken,
105
100
  buy_tokens: buyToken,
@@ -115,8 +110,7 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
115
110
  if (affiliateBps && affiliateBps !== '0') {
116
111
  params.set('fee', affiliateBps);
117
112
  }
118
- const bebopService = (0, bebopService_1.bebopServiceFactory)({ apiKey });
119
- const maybeResponse = await bebopService.get(`${url}?${params}`);
113
+ const maybeResponse = await (0, bebopService_1.bebopServiceFactory)({ apiKey }).get('https://api.bebop.xyz/pmm/solana/v3/quote', { params });
120
114
  if (maybeResponse.isErr()) {
121
115
  const err = maybeResponse.unwrapErr();
122
116
  return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
@@ -138,19 +132,6 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
138
132
  code: types_1.TradeQuoteError.InvalidResponse,
139
133
  }));
140
134
  }
141
- // Reject routes containing ANY AMM/CLMM makers - these produce malformed txs
142
- // (wrong signature count in wire format) and require pre-existing ATAs that
143
- // Bebop's gasless co-signed flow can't create. This includes mixed routes
144
- // like ["raydium clmm-rfqm", "🦊"] where Bebop serializes the tx with fewer
145
- // signature slots than the message header requires.
146
- // When rejected, other swappers like Jupiter will handle these pairs instead.
147
- const hasAmmRoute = response.data.makers.some(maker => maker.toLowerCase().includes('clmm') || maker.toLowerCase().includes('amm'));
148
- if (hasAmmRoute) {
149
- return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
150
- message: `Bebop Solana quote contains AMM routing (${response.data.makers.join(', ')}), which produces malformed txs`,
151
- code: types_1.TradeQuoteError.NoRouteFound,
152
- }));
153
- }
154
135
  return (0, monads_1.Ok)(response.data);
155
136
  }
156
137
  catch (error) {
@@ -162,17 +143,3 @@ const fetchBebopSolanaQuote = async ({ buyAsset, sellAsset, sellAmountIncludingP
162
143
  }
163
144
  };
164
145
  exports.fetchBebopSolanaQuote = fetchBebopSolanaQuote;
165
- const fetchBebopSolanaPrice = ({ buyAsset, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, affiliateBps, apiKey, }) => {
166
- const address = receiveAddress || types_2.BEBOP_SOLANA_DUMMY_ADDRESS;
167
- return (0, exports.fetchBebopSolanaQuote)({
168
- buyAsset,
169
- sellAsset,
170
- sellAmountIncludingProtocolFeesCryptoBaseUnit,
171
- takerAddress: address,
172
- receiverAddress: address,
173
- slippageTolerancePercentageDecimal: '0.01',
174
- affiliateBps,
175
- apiKey,
176
- });
177
- };
178
- exports.fetchBebopSolanaPrice = fetchBebopSolanaPrice;
@@ -0,0 +1,2 @@
1
+ import type { Swapper } from '../../types';
2
+ export declare const bobGatewaySwapper: Swapper;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bobGatewaySwapper = void 0;
4
+ const utils_1 = require("../../utils");
5
+ exports.bobGatewaySwapper = {
6
+ executeEvmTransaction: utils_1.executeEvmTransaction,
7
+ executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => signAndBroadcastTransaction(txToSign),
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { SwapperApi } from '../../types';
2
+ export declare const bobGatewayApi: SwapperApi;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bobGatewayApi = void 0;
4
+ const bob_sdk_1 = require("@gobob/bob-sdk");
5
+ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
6
+ const unchained_client_1 = require("@shapeshiftoss/unchained-client");
7
+ const utils_1 = require("@shapeshiftoss/utils");
8
+ const utils_2 = require("../../utils");
9
+ const getTradeQuote_1 = require("./swapperApi/getTradeQuote");
10
+ const getTradeRate_1 = require("./swapperApi/getTradeRate");
11
+ const helpers_1 = require("./utils/helpers");
12
+ const registeredSwapIds = new Set();
13
+ exports.bobGatewayApi = {
14
+ getTradeRate: async (input, deps) => {
15
+ return (await (0, getTradeRate_1.getBobGatewayTradeRate)(input, deps)).map(tradeRate => [tradeRate]);
16
+ },
17
+ getTradeQuote: async (input, deps) => {
18
+ return (await (0, getTradeQuote_1.getBobGatewayTradeQuote)(input, deps)).map(tradeQuote => [tradeQuote]);
19
+ },
20
+ getUnsignedUtxoTransaction: ({ stepIndex, tradeQuote, xpub, accountType, assertGetUtxoChainAdapter, }) => {
21
+ if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
22
+ throw new Error('[BobGateway] unable to execute a trade rate');
23
+ }
24
+ const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
25
+ const { bobSpecific, sellAsset } = step;
26
+ const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
27
+ if (!bobSpecific?.utxoTx)
28
+ throw new Error('[BobGateway] invalid utxo transaction');
29
+ const { depositAddress, opReturnData } = bobSpecific.utxoTx;
30
+ return adapter.buildSendApiTransaction({
31
+ value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
32
+ xpub,
33
+ to: depositAddress,
34
+ accountNumber: step.accountNumber,
35
+ skipToAddressValidation: true,
36
+ chainSpecific: {
37
+ accountType,
38
+ opReturnData,
39
+ satoshiPerByte: step.feeData.chainSpecific.satsPerByte,
40
+ },
41
+ });
42
+ },
43
+ getUtxoTransactionFees: async ({ stepIndex, tradeQuote, xpub, assertGetUtxoChainAdapter }) => {
44
+ if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
45
+ throw new Error('[BobGateway] unable to execute a trade rate');
46
+ }
47
+ const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
48
+ const { bobSpecific, sellAsset } = step;
49
+ const adapter = assertGetUtxoChainAdapter(sellAsset.chainId);
50
+ if (!bobSpecific?.utxoTx)
51
+ throw new Error('[BobGateway] invalid utxo transaction');
52
+ const { depositAddress, opReturnData } = bobSpecific.utxoTx;
53
+ const { fast } = await adapter.getFeeData({
54
+ to: depositAddress,
55
+ value: step.sellAmountIncludingProtocolFeesCryptoBaseUnit,
56
+ chainSpecific: { pubkey: xpub, opReturnData },
57
+ sendMax: false,
58
+ });
59
+ return fast.txFee;
60
+ },
61
+ getUnsignedEvmTransaction: async ({ from, stepIndex, tradeQuote, assertGetEvmChainAdapter, supportsEIP1559, }) => {
62
+ if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
63
+ throw new Error('[BobGateway] unable to execute a trade rate');
64
+ }
65
+ const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
66
+ const { accountNumber, bobSpecific, sellAsset } = step;
67
+ const adapter = assertGetEvmChainAdapter(sellAsset.chainId);
68
+ if (!bobSpecific?.evmTx)
69
+ throw new Error('[BobGateway] invalid evm transaction');
70
+ const { to, data, value } = bobSpecific.evmTx;
71
+ const feeData = await chain_adapters_1.evm.getFees({ adapter, data, to, value, from, supportsEIP1559 });
72
+ // Pad the gas limit of the tx we actually broadcast to reduce the risk of out-of-gas reverts.
73
+ const gasLimit = (0, utils_1.bnOrZero)(feeData.gasLimit).times(1.2).toFixed(0);
74
+ return adapter.buildCustomApiTx({
75
+ accountNumber,
76
+ from,
77
+ to,
78
+ value,
79
+ data,
80
+ ...feeData,
81
+ gasLimit,
82
+ });
83
+ },
84
+ getEvmTransactionFees: async ({ from, stepIndex, tradeQuote, supportsEIP1559, assertGetEvmChainAdapter, }) => {
85
+ if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote)) {
86
+ throw new Error('[BobGateway] unable to execute a trade rate');
87
+ }
88
+ const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
89
+ const { bobSpecific, sellAsset } = step;
90
+ const adapter = assertGetEvmChainAdapter(sellAsset.chainId);
91
+ if (!bobSpecific?.evmTx)
92
+ throw new Error('[BobGateway] invalid evm transaction');
93
+ const { to, data, value } = bobSpecific.evmTx;
94
+ const feeData = await chain_adapters_1.evm.getFees({ adapter, data, to, value, from, supportsEIP1559 });
95
+ return feeData.networkFeeCryptoBaseUnit;
96
+ },
97
+ checkTradeStatus: async ({ swap, config, txHash }) => {
98
+ if (!swap)
99
+ throw new Error('[BobGateway] swap is required for status check');
100
+ const orderId = swap.metadata.bobSpecific?.orderId;
101
+ if (!orderId)
102
+ throw new Error('[BobGateway] orderId is required for status check');
103
+ if (txHash && !registeredSwapIds.has(swap.id)) {
104
+ try {
105
+ await (0, helpers_1.registerBobGatewayTx)({
106
+ config,
107
+ orderId,
108
+ txHash,
109
+ sellAsset: swap.sellAsset,
110
+ buyAsset: swap.buyAsset,
111
+ });
112
+ registeredSwapIds.add(swap.id);
113
+ }
114
+ catch { }
115
+ }
116
+ let orderInfo;
117
+ try {
118
+ orderInfo = await (0, helpers_1.getBobGatewayClient)(config).getOrder(orderId);
119
+ }
120
+ catch (err) {
121
+ if ((0, bob_sdk_1.isGatewayError)(err)) {
122
+ if (err.code === 'ORDER_NOT_FOUND') {
123
+ return {
124
+ buyTxHash: undefined,
125
+ status: unchained_client_1.TxStatus.Unknown,
126
+ message: 'Waiting for deposit...',
127
+ };
128
+ }
129
+ }
130
+ throw err;
131
+ }
132
+ const status = (0, helpers_1.mapBobGatewayOrderStatusToTxStatus)(orderInfo.status);
133
+ const buyTxHash = 'success' in orderInfo.status ? orderInfo.status.success.receivedTokens[0]?.txHash : undefined;
134
+ const refundTxHash = 'refunded' in orderInfo.status
135
+ ? orderInfo.status.refunded.refundedTokens[0]?.txHash
136
+ : undefined;
137
+ return {
138
+ status,
139
+ buyTxHash,
140
+ message: refundTxHash ? 'Trade refunded' : undefined,
141
+ };
142
+ },
143
+ };
@@ -0,0 +1,3 @@
1
+ export { bobGatewayApi } from './endpoints';
2
+ export { bobGatewaySwapper } from './BobGatewaySwapper';
3
+ export * from './utils/constants';
@@ -0,0 +1,22 @@
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.bobGatewaySwapper = exports.bobGatewayApi = void 0;
18
+ var endpoints_1 = require("./endpoints");
19
+ Object.defineProperty(exports, "bobGatewayApi", { enumerable: true, get: function () { return endpoints_1.bobGatewayApi; } });
20
+ var BobGatewaySwapper_1 = require("./BobGatewaySwapper");
21
+ Object.defineProperty(exports, "bobGatewaySwapper", { enumerable: true, get: function () { return BobGatewaySwapper_1.bobGatewaySwapper; } });
22
+ __exportStar(require("./utils/constants"), exports);
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { CommonTradeQuoteInput, SwapErrorRight, SwapperDeps, TradeQuote } from '../../../types';
3
+ export declare const getBobGatewayTradeQuote: (input: CommonTradeQuoteInput, deps: SwapperDeps) => Promise<Result<TradeQuote, SwapErrorRight>>;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBobGatewayTradeQuote = void 0;
4
+ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
5
+ const monads_1 = require("@sniptt/monads");
6
+ const uuid_1 = require("uuid");
7
+ const types_1 = require("../../../types");
8
+ const utils_1 = require("../../../utils");
9
+ const helpers_1 = require("../utils/helpers");
10
+ const getBobGatewayTradeQuote = async (input, deps) => {
11
+ const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, sendAddress, receiveAddress, accountNumber, affiliateBps, slippageTolerancePercentageDecimal, } = input;
12
+ const { config } = deps;
13
+ if (!sendAddress) {
14
+ return (0, monads_1.Err)((0, utils_1.makeSwapErrorRight)({
15
+ message: '[BobGateway] sendAddress is required for quote',
16
+ code: types_1.TradeQuoteError.UnknownError,
17
+ }));
18
+ }
19
+ if (!receiveAddress) {
20
+ return (0, monads_1.Err)((0, utils_1.makeSwapErrorRight)({
21
+ message: '[BobGateway] receiveAddress is required for quote',
22
+ code: types_1.TradeQuoteError.UnknownError,
23
+ }));
24
+ }
25
+ const assertion = (0, helpers_1.assertValidTrade)({ sellAsset, buyAsset });
26
+ if (assertion.isErr())
27
+ return (0, monads_1.Err)(assertion.unwrapErr());
28
+ const { sellChainName, buyChainName } = assertion.unwrap();
29
+ // omit the sender for utxo sells so order creation does not enforce a per-address confirmed
30
+ // funds check (deposits are matched via op_return, not the sending address)
31
+ const sender = (0, chain_adapters_1.isEvmChainId)(sellAsset.chainId) ? sendAddress : undefined;
32
+ const maybeQuote = await (0, helpers_1.getBobGatewayQuote)({
33
+ config,
34
+ sellAsset,
35
+ buyAsset,
36
+ sellChainName,
37
+ buyChainName,
38
+ sender,
39
+ recipient: receiveAddress,
40
+ amount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
41
+ affiliateBps,
42
+ slippageTolerancePercentageDecimal,
43
+ });
44
+ if (maybeQuote.isErr())
45
+ return (0, monads_1.Err)(maybeQuote.unwrapErr());
46
+ const quote = maybeQuote.unwrap();
47
+ const maybeOrderMetadata = await (0, helpers_1.createBobGatewayOrderMetadata)(config, quote);
48
+ if (maybeOrderMetadata.isErr())
49
+ return (0, monads_1.Err)(maybeOrderMetadata.unwrapErr());
50
+ const orderMetadata = maybeOrderMetadata.unwrap();
51
+ const maybeFeeData = await (0, helpers_1.getBobGatewayQuoteFeeData)(input, deps, orderMetadata);
52
+ if (maybeFeeData.isErr())
53
+ return (0, monads_1.Err)(maybeFeeData.unwrapErr());
54
+ const feeData = maybeFeeData.unwrap();
55
+ const { buyAmountBeforeFeesCryptoBaseUnit, buyAmountAfterFeesCryptoBaseUnit, protocolFees, estimatedExecutionTimeMs, } = (0, helpers_1.parseBobGatewayQuote)(quote, buyAsset, deps.assetsById);
56
+ const rate = (0, utils_1.getInputOutputRate)({
57
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
58
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
59
+ sellAsset,
60
+ buyAsset,
61
+ });
62
+ const allowanceContract = (0, helpers_1.getBobGatewayAllowanceContract)(quote, sellAsset);
63
+ const tradeQuote = {
64
+ id: (0, uuid_1.v4)(),
65
+ quoteOrRate: 'quote',
66
+ rate,
67
+ receiveAddress,
68
+ affiliateBps,
69
+ slippageTolerancePercentageDecimal,
70
+ swapperName: types_1.SwapperName.BobGateway,
71
+ steps: [
72
+ {
73
+ buyAmountBeforeFeesCryptoBaseUnit,
74
+ buyAmountAfterFeesCryptoBaseUnit,
75
+ sellAmountIncludingProtocolFeesCryptoBaseUnit,
76
+ feeData: { ...feeData, protocolFees },
77
+ rate,
78
+ source: types_1.SwapperName.BobGateway,
79
+ buyAsset,
80
+ sellAsset,
81
+ accountNumber,
82
+ allowanceContract,
83
+ estimatedExecutionTimeMs,
84
+ bobSpecific: orderMetadata,
85
+ },
86
+ ],
87
+ };
88
+ return (0, monads_1.Ok)(tradeQuote);
89
+ };
90
+ exports.getBobGatewayTradeQuote = getBobGatewayTradeQuote;
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@sniptt/monads';
2
+ import type { GetTradeRateInput, SwapErrorRight, SwapperDeps, TradeRate } from '../../../types';
3
+ export declare const getBobGatewayTradeRate: (input: GetTradeRateInput, deps: SwapperDeps) => Promise<Result<TradeRate, SwapErrorRight>>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBobGatewayTradeRate = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
5
+ const monads_1 = require("@sniptt/monads");
6
+ const uuid_1 = require("uuid");
7
+ const types_1 = require("../../../types");
8
+ const utils_1 = require("../../../utils");
9
+ const constants_1 = require("../utils/constants");
10
+ const helpers_1 = require("../utils/helpers");
11
+ const getBobGatewayTradeRate = async (input, deps) => {
12
+ const { sellAsset, buyAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, accountNumber, affiliateBps, slippageTolerancePercentageDecimal, } = input;
13
+ const { config } = deps;
14
+ const assertion = (0, helpers_1.assertValidTrade)({ sellAsset, buyAsset });
15
+ if (assertion.isErr())
16
+ return (0, monads_1.Err)(assertion.unwrapErr());
17
+ const { sellChainName, buyChainName } = assertion.unwrap();
18
+ const recipient = receiveAddress ?? (buyAsset.chainId === caip_1.btcChainId ? constants_1.DUMMY_BTC_ADDRESS : constants_1.DUMMY_EVM_ADDRESS);
19
+ const sender = sellAsset.chainId === caip_1.btcChainId ? undefined : constants_1.DUMMY_EVM_ADDRESS;
20
+ const maybeQuote = await (0, helpers_1.getBobGatewayQuote)({
21
+ config,
22
+ sellAsset,
23
+ buyAsset,
24
+ sellChainName,
25
+ buyChainName,
26
+ sender,
27
+ recipient,
28
+ amount: sellAmountIncludingProtocolFeesCryptoBaseUnit,
29
+ affiliateBps,
30
+ slippageTolerancePercentageDecimal,
31
+ });
32
+ if (maybeQuote.isErr())
33
+ return (0, monads_1.Err)(maybeQuote.unwrapErr());
34
+ const quote = maybeQuote.unwrap();
35
+ const { buyAmountBeforeFeesCryptoBaseUnit, buyAmountAfterFeesCryptoBaseUnit, protocolFees, estimatedExecutionTimeMs, } = (0, helpers_1.parseBobGatewayQuote)(quote, buyAsset, deps.assetsById);
36
+ const rate = (0, utils_1.getInputOutputRate)({
37
+ sellAmountCryptoBaseUnit: sellAmountIncludingProtocolFeesCryptoBaseUnit,
38
+ buyAmountCryptoBaseUnit: buyAmountAfterFeesCryptoBaseUnit,
39
+ sellAsset,
40
+ buyAsset,
41
+ });
42
+ const allowanceContract = (0, helpers_1.getBobGatewayAllowanceContract)(quote, sellAsset);
43
+ const networkFeeCryptoBaseUnit = await (0, helpers_1.getBobGatewayRateNetworkFeeCryptoBaseUnit)(quote, sellAsset, deps);
44
+ const tradeRate = {
45
+ id: (0, uuid_1.v4)(),
46
+ quoteOrRate: 'rate',
47
+ rate,
48
+ receiveAddress,
49
+ affiliateBps,
50
+ slippageTolerancePercentageDecimal,
51
+ swapperName: types_1.SwapperName.BobGateway,
52
+ steps: [
53
+ {
54
+ buyAmountBeforeFeesCryptoBaseUnit,
55
+ buyAmountAfterFeesCryptoBaseUnit,
56
+ sellAmountIncludingProtocolFeesCryptoBaseUnit,
57
+ feeData: {
58
+ networkFeeCryptoBaseUnit,
59
+ protocolFees,
60
+ },
61
+ rate,
62
+ source: types_1.SwapperName.BobGateway,
63
+ buyAsset,
64
+ sellAsset,
65
+ accountNumber,
66
+ allowanceContract,
67
+ estimatedExecutionTimeMs,
68
+ },
69
+ ],
70
+ };
71
+ return (0, monads_1.Ok)(tradeRate);
72
+ };
73
+ exports.getBobGatewayTradeRate = getBobGatewayTradeRate;
@@ -0,0 +1,20 @@
1
+ type BobGatewayEvmTxMetadata = {
2
+ to: string;
3
+ data: string;
4
+ value: string;
5
+ chain: string;
6
+ };
7
+ type BobGatewayUtxoTxMetadata = {
8
+ depositAddress: string;
9
+ opReturnData?: string;
10
+ };
11
+ export type BobGatewayMetadata = {
12
+ orderId: string;
13
+ } & ({
14
+ evmTx: BobGatewayEvmTxMetadata;
15
+ utxoTx?: never;
16
+ } | {
17
+ utxoTx: BobGatewayUtxoTxMetadata;
18
+ evmTx?: never;
19
+ });
20
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type { ChainId } from '@shapeshiftoss/caip';
2
+ export declare const BOB_GATEWAY_BASE_URL = "https://gateway-api-mainnet.gobob.xyz";
3
+ export declare const chainIdToBobGatewayChainName: {
4
+ readonly [x: string]: "arbitrum" | "avalanche" | "base" | "bera" | "bitcoin" | "bob" | "bsc" | "ethereum" | "sei" | "sonic" | "unichain";
5
+ };
6
+ export declare const bobGatewayChainNameToChainId: Record<BobGatewayChainName, ChainId>;
7
+ export type BobGatewayChainName = (typeof chainIdToBobGatewayChainName)[keyof typeof chainIdToBobGatewayChainName];
8
+ export declare const DUMMY_EVM_ADDRESS: `0x${string}`;
9
+ export declare const DUMMY_BTC_ADDRESS = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq";
10
+ export declare const BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = "350000";
11
+ export declare const BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = "550000";
12
+ export declare const BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE = "200";
13
+ export declare const decimalSlippageToBobBps: (slippageDecimal: string) => string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decimalSlippageToBobBps = exports.BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE = exports.BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = exports.BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = exports.DUMMY_BTC_ADDRESS = exports.DUMMY_EVM_ADDRESS = exports.bobGatewayChainNameToChainId = exports.chainIdToBobGatewayChainName = exports.BOB_GATEWAY_BASE_URL = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
5
+ exports.BOB_GATEWAY_BASE_URL = 'https://gateway-api-mainnet.gobob.xyz';
6
+ // Chain name strings expected by the BOB Gateway API
7
+ // https://gateway-api-mainnet.gobob.xyz/v2/get-routes
8
+ exports.chainIdToBobGatewayChainName = {
9
+ [caip_1.arbitrumChainId]: 'arbitrum',
10
+ [caip_1.avalancheChainId]: 'avalanche',
11
+ [caip_1.baseChainId]: 'base',
12
+ [caip_1.berachainChainId]: 'bera',
13
+ [caip_1.btcChainId]: 'bitcoin',
14
+ [caip_1.bobChainId]: 'bob',
15
+ [caip_1.bscChainId]: 'bsc',
16
+ [caip_1.ethChainId]: 'ethereum',
17
+ [caip_1.seiChainId]: 'sei',
18
+ [caip_1.sonicChainId]: 'sonic',
19
+ [caip_1.unichainChainId]: 'unichain',
20
+ };
21
+ exports.bobGatewayChainNameToChainId = Object.fromEntries(Object.entries(exports.chainIdToBobGatewayChainName).map(([chainId, chainName]) => [chainName, chainId]));
22
+ exports.DUMMY_EVM_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
23
+ exports.DUMMY_BTC_ADDRESS = 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq';
24
+ exports.BOB_GATEWAY_TOKENSWAP_DEFAULT_GAS_LIMIT = '350000'; // EVM→EVM
25
+ exports.BOB_GATEWAY_OFFRAMP_DEFAULT_GAS_LIMIT = '550000'; // EVM→BTC
26
+ exports.BOB_GATEWAY_ONRAMP_DEFAULT_TX_VSIZE = '200'; // BTC→EVM
27
+ // https://docs.gobob.xyz/api-reference/v2/get-a-gateway-quote#parameter-slippage
28
+ const decimalSlippageToBobBps = (slippageDecimal) => {
29
+ return String(Math.round(parseFloat(slippageDecimal) * 10_000));
30
+ };
31
+ exports.decimalSlippageToBobBps = decimalSlippageToBobBps;