@shapeshiftoss/swapper 17.6.8 → 17.6.10
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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/constants.js +61 -43
- package/dist/cjs/swappers/AcrossSwapper/AcrossSwapper.d.ts +2 -0
- package/dist/cjs/swappers/AcrossSwapper/AcrossSwapper.js +8 -0
- package/dist/cjs/swappers/AcrossSwapper/constant.d.ts +9 -0
- package/dist/cjs/swappers/AcrossSwapper/constant.js +48 -0
- package/dist/cjs/swappers/AcrossSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/AcrossSwapper/endpoints.js +113 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.js +31 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeRate/getTradeRate.d.ts +3 -0
- package/dist/cjs/swappers/AcrossSwapper/getTradeRate/getTradeRate.js +19 -0
- package/dist/cjs/swappers/AcrossSwapper/index.d.ts +1 -0
- package/dist/cjs/swappers/AcrossSwapper/index.js +5 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.d.ts +5 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/acrossService.js +17 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/fetchAcrossTrade.d.ts +19 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/fetchAcrossTrade.js +27 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.d.ts +11 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/getTrade.js +335 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/types.d.ts +177 -0
- package/dist/cjs/swappers/AcrossSwapper/utils/types.js +17 -0
- package/dist/cjs/swappers/AvnuSwapper/endpoints.js +42 -14
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +10 -5
- package/dist/cjs/swappers/AvnuSwapper/swapperApi/getTradeRate.js +8 -4
- package/dist/cjs/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -1
- package/dist/cjs/swappers/ButterSwap/ButterSwap.js +1 -0
- package/dist/cjs/swappers/ButterSwap/endpoints.js +56 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/checkTradeStatus.js +19 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.js +27 -14
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +1 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.js +23 -16
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.test.js +2 -0
- package/dist/cjs/swappers/ButterSwap/types.d.ts +1 -0
- package/dist/cjs/swappers/ButterSwap/utils/helpers.js +1 -0
- package/dist/cjs/swappers/ButterSwap/xhr.d.ts +2 -2
- package/dist/cjs/swappers/ButterSwap/xhr.js +7 -2
- package/dist/cjs/swappers/CetusSwapper/endpoints.js +3 -8
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +1 -1
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +1 -1
- package/dist/cjs/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +11 -5
- package/dist/cjs/swappers/ChainflipSwapper/utils/helpers.js +8 -2
- package/dist/cjs/swappers/CowSwapper/CowSwapper.js +1 -1
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -1
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +5 -5
- package/dist/cjs/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +1 -1
- package/dist/cjs/swappers/CowSwapper/utils/helpers/helpers.js +8 -2
- package/dist/cjs/swappers/NearIntentsSwapper/NearIntentsSwapper.js +1 -0
- package/dist/cjs/swappers/NearIntentsSwapper/endpoints.js +31 -0
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +36 -1
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +61 -1
- package/dist/cjs/swappers/NearIntentsSwapper/types.d.ts +1 -1
- package/dist/cjs/swappers/NearIntentsSwapper/types.js +6 -0
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +23 -4
- package/dist/cjs/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +8 -3
- package/dist/cjs/swappers/RelaySwapper/constant.js +26 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +13 -2
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +100 -0
- package/dist/cjs/swappers/RelaySwapper/utils/types.d.ts +15 -0
- package/dist/cjs/swappers/StonfiSwapper/StonfiSwapper.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/StonfiSwapper.js +8 -0
- package/dist/cjs/swappers/StonfiSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/endpoints.js +227 -0
- package/dist/cjs/swappers/StonfiSwapper/index.d.ts +4 -0
- package/dist/cjs/swappers/StonfiSwapper/index.js +25 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +119 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.d.ts +2 -0
- package/dist/cjs/swappers/StonfiSwapper/swapperApi/getTradeRate.js +105 -0
- package/dist/cjs/swappers/StonfiSwapper/types.d.ts +60 -0
- package/dist/cjs/swappers/StonfiSwapper/types.js +5 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/constants.d.ts +5 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/constants.js +8 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/helpers.d.ts +11 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/helpers.js +135 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/omnistonManager.d.ts +5 -0
- package/dist/cjs/swappers/StonfiSwapper/utils/omnistonManager.js +20 -0
- package/dist/cjs/swappers/SunioSwapper/endpoints.js +1 -1
- package/dist/cjs/swappers/SunioSwapper/utils/getQuoteOrRate.js +4 -3
- package/dist/cjs/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +1 -1
- package/dist/cjs/swappers/utils/filterBuyAssetsBySellAssetId/filterBuyAssetsBySellAssetId.js +2 -5
- package/dist/cjs/swappers/utils/helpers/helpers.js +3 -0
- package/dist/cjs/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +30 -5
- package/dist/cjs/thorchain-utils/getQuote.js +8 -2
- package/dist/cjs/tron-utils/getUnsignedTronTransaction.js +22 -2
- package/dist/cjs/types.d.ts +79 -8
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils.d.ts +4 -3
- package/dist/cjs/utils.js +35 -7
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +31 -13
- package/dist/esm/swappers/AcrossSwapper/AcrossSwapper.d.ts +2 -0
- package/dist/esm/swappers/AcrossSwapper/AcrossSwapper.js +5 -0
- package/dist/esm/swappers/AcrossSwapper/constant.d.ts +9 -0
- package/dist/esm/swappers/AcrossSwapper/constant.js +42 -0
- package/dist/esm/swappers/AcrossSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/AcrossSwapper/endpoints.js +107 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.d.ts +3 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeQuote/getTradeQuote.js +27 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeRate/getTradeRate.d.ts +3 -0
- package/dist/esm/swappers/AcrossSwapper/getTradeRate/getTradeRate.js +15 -0
- package/dist/esm/swappers/AcrossSwapper/index.d.ts +1 -0
- package/dist/esm/swappers/AcrossSwapper/index.js +1 -0
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.d.ts +5 -0
- package/dist/esm/swappers/AcrossSwapper/utils/acrossService.js +11 -0
- package/dist/esm/swappers/AcrossSwapper/utils/fetchAcrossTrade.d.ts +19 -0
- package/dist/esm/swappers/AcrossSwapper/utils/fetchAcrossTrade.js +23 -0
- package/dist/esm/swappers/AcrossSwapper/utils/getTrade.d.ts +11 -0
- package/dist/esm/swappers/AcrossSwapper/utils/getTrade.js +328 -0
- package/dist/esm/swappers/AcrossSwapper/utils/types.d.ts +177 -0
- package/dist/esm/swappers/AcrossSwapper/utils/types.js +13 -0
- package/dist/esm/swappers/AvnuSwapper/endpoints.js +43 -15
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeQuote.js +10 -5
- package/dist/esm/swappers/AvnuSwapper/swapperApi/getTradeRate.js +8 -4
- package/dist/esm/swappers/BebopSwapper/utils/helpers/helpers.d.ts +1 -1
- package/dist/esm/swappers/ButterSwap/ButterSwap.js +2 -1
- package/dist/esm/swappers/ButterSwap/endpoints.js +56 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/checkTradeStatus.js +20 -1
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.js +29 -16
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +1 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.js +25 -18
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.test.js +2 -0
- package/dist/esm/swappers/ButterSwap/types.d.ts +1 -0
- package/dist/esm/swappers/ButterSwap/utils/helpers.js +1 -0
- package/dist/esm/swappers/ButterSwap/xhr.d.ts +2 -2
- package/dist/esm/swappers/ButterSwap/xhr.js +8 -3
- package/dist/esm/swappers/CetusSwapper/endpoints.js +3 -8
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +1 -1
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +1 -1
- package/dist/esm/swappers/ChainflipSwapper/utils/getQuoteOrRate.js +12 -6
- package/dist/esm/swappers/ChainflipSwapper/utils/helpers.js +9 -3
- package/dist/esm/swappers/CowSwapper/CowSwapper.js +1 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.js +1 -1
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeQuote/getCowSwapTradeQuote.test.js +5 -5
- package/dist/esm/swappers/CowSwapper/getCowSwapTradeRate/getCowSwapTradeRate.js +1 -1
- package/dist/esm/swappers/CowSwapper/utils/helpers/helpers.js +9 -3
- package/dist/esm/swappers/NearIntentsSwapper/NearIntentsSwapper.js +2 -1
- package/dist/esm/swappers/NearIntentsSwapper/endpoints.js +31 -0
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +36 -1
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +61 -1
- package/dist/esm/swappers/NearIntentsSwapper/types.d.ts +1 -1
- package/dist/esm/swappers/NearIntentsSwapper/types.js +6 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +23 -4
- package/dist/esm/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.js +8 -3
- package/dist/esm/swappers/RelaySwapper/constant.js +28 -3
- package/dist/esm/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +13 -2
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +100 -0
- package/dist/esm/swappers/RelaySwapper/utils/types.d.ts +15 -0
- package/dist/esm/swappers/StonfiSwapper/StonfiSwapper.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/StonfiSwapper.js +5 -0
- package/dist/esm/swappers/StonfiSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/endpoints.js +224 -0
- package/dist/esm/swappers/StonfiSwapper/index.d.ts +4 -0
- package/dist/esm/swappers/StonfiSwapper/index.js +4 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeQuote.js +115 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.d.ts +2 -0
- package/dist/esm/swappers/StonfiSwapper/swapperApi/getTradeRate.js +101 -0
- package/dist/esm/swappers/StonfiSwapper/types.d.ts +60 -0
- package/dist/esm/swappers/StonfiSwapper/types.js +2 -0
- package/dist/esm/swappers/StonfiSwapper/utils/constants.d.ts +5 -0
- package/dist/esm/swappers/StonfiSwapper/utils/constants.js +5 -0
- package/dist/esm/swappers/StonfiSwapper/utils/helpers.d.ts +11 -0
- package/dist/esm/swappers/StonfiSwapper/utils/helpers.js +124 -0
- package/dist/esm/swappers/StonfiSwapper/utils/omnistonManager.d.ts +5 -0
- package/dist/esm/swappers/StonfiSwapper/utils/omnistonManager.js +17 -0
- package/dist/esm/swappers/SunioSwapper/endpoints.js +1 -1
- package/dist/esm/swappers/SunioSwapper/utils/getQuoteOrRate.js +5 -4
- package/dist/esm/swappers/ZrxSwapper/utils/helpers/helpers.d.ts +1 -1
- package/dist/esm/swappers/utils/filterBuyAssetsBySellAssetId/filterBuyAssetsBySellAssetId.js +2 -5
- package/dist/esm/swappers/utils/helpers/helpers.js +4 -1
- package/dist/esm/thorchain-utils/getCallDataFromQuote.d.ts +1 -1
- package/dist/esm/thorchain-utils/getL1RateOrQuote.js +31 -6
- package/dist/esm/thorchain-utils/getQuote.js +9 -3
- package/dist/esm/tron-utils/getUnsignedTronTransaction.js +22 -2
- package/dist/esm/types.d.ts +79 -8
- package/dist/esm/types.js +2 -0
- package/dist/esm/utils.d.ts +4 -3
- package/dist/esm/utils.js +34 -7
- package/package.json +17 -15
|
@@ -63,8 +63,14 @@ const getValuesFromQuoteResponse = ({ buyAsset, sellAsset, response, affiliateBp
|
|
|
63
63
|
amount: buyAmountAfterAffiliateFeesCryptoBaseUnit,
|
|
64
64
|
slippageTolerancePercentageDecimal,
|
|
65
65
|
});
|
|
66
|
-
const buyAmountAfterAffiliateFeesCryptoPrecision =
|
|
67
|
-
|
|
66
|
+
const buyAmountAfterAffiliateFeesCryptoPrecision = utils_1.BigAmount.fromBaseUnit({
|
|
67
|
+
value: buyAmountAfterAffiliateFeesCryptoBaseUnit,
|
|
68
|
+
precision: buyAsset.precision,
|
|
69
|
+
}).toPrecision();
|
|
70
|
+
const sellAmountCryptoPrecision = utils_1.BigAmount.fromBaseUnit({
|
|
71
|
+
value: sellAmountAfterFeesCryptoBaseUnit,
|
|
72
|
+
precision: sellAsset.precision,
|
|
73
|
+
}).toPrecision();
|
|
68
74
|
const rate = (0, utils_1.bnOrZero)(buyAmountAfterAffiliateFeesCryptoPrecision)
|
|
69
75
|
.div(sellAmountCryptoPrecision)
|
|
70
76
|
.toString();
|
|
@@ -9,6 +9,7 @@ exports.nearIntentsSwapper = {
|
|
|
9
9
|
executeTronTransaction: utils_1.executeTronTransaction,
|
|
10
10
|
executeSuiTransaction: utils_1.executeSuiTransaction,
|
|
11
11
|
executeNearTransaction: utils_1.executeNearTransaction,
|
|
12
|
+
executeTonTransaction: utils_1.executeTonTransaction,
|
|
12
13
|
executeUtxoTransaction: (txToSign, { signAndBroadcastTransaction }) => {
|
|
13
14
|
return signAndBroadcastTransaction(txToSign);
|
|
14
15
|
},
|
|
@@ -248,6 +248,37 @@ exports.nearIntentsApi = {
|
|
|
248
248
|
}
|
|
249
249
|
return Promise.resolve(step.feeData.networkFeeCryptoBaseUnit);
|
|
250
250
|
},
|
|
251
|
+
getUnsignedTonTransaction: ({ stepIndex, tradeQuote, from, assertGetTonChainAdapter, }) => {
|
|
252
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
|
|
253
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
254
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
255
|
+
const { accountNumber, sellAsset, nearIntentsSpecific } = step;
|
|
256
|
+
if (!nearIntentsSpecific)
|
|
257
|
+
throw new Error('nearIntentsSpecific is required');
|
|
258
|
+
const adapter = assertGetTonChainAdapter(sellAsset.chainId);
|
|
259
|
+
const to = nearIntentsSpecific.depositAddress;
|
|
260
|
+
const value = step.sellAmountIncludingProtocolFeesCryptoBaseUnit;
|
|
261
|
+
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
262
|
+
return adapter.buildSendApiTransaction({
|
|
263
|
+
to,
|
|
264
|
+
from,
|
|
265
|
+
value,
|
|
266
|
+
accountNumber,
|
|
267
|
+
chainSpecific: {
|
|
268
|
+
contractAddress,
|
|
269
|
+
memo: nearIntentsSpecific.depositMemo,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
getTonTransactionFees: ({ tradeQuote, stepIndex }) => {
|
|
274
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
|
|
275
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
276
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
277
|
+
if (!step.feeData.networkFeeCryptoBaseUnit) {
|
|
278
|
+
throw new Error('Missing network fee in quote');
|
|
279
|
+
}
|
|
280
|
+
return Promise.resolve(step.feeData.networkFeeCryptoBaseUnit);
|
|
281
|
+
},
|
|
251
282
|
checkTradeStatus: async ({ config, swap }) => {
|
|
252
283
|
const { nearIntentsSpecific } = swap?.metadata ?? {};
|
|
253
284
|
if (!nearIntentsSpecific?.depositAddress) {
|
|
@@ -74,7 +74,27 @@ const getTradeQuote = async (input, deps) => {
|
|
|
74
74
|
},
|
|
75
75
|
],
|
|
76
76
|
};
|
|
77
|
-
const
|
|
77
|
+
const maxRetries = 3;
|
|
78
|
+
let quoteResponse = null;
|
|
79
|
+
let lastError = null;
|
|
80
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
81
|
+
try {
|
|
82
|
+
quoteResponse = await oneClickService_1.OneClickService.getQuote(quoteRequest);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
87
|
+
const isWebSocketError = lastError.message.includes('WebSocket is not ready');
|
|
88
|
+
if (isWebSocketError && attempt < maxRetries) {
|
|
89
|
+
await new Promise(resolve => setTimeout(resolve, 1000 * attempt));
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
throw lastError;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!quoteResponse) {
|
|
96
|
+
throw lastError ?? new Error('Failed to get quote after retries');
|
|
97
|
+
}
|
|
78
98
|
const { quote } = quoteResponse;
|
|
79
99
|
if (!quote.depositAddress) {
|
|
80
100
|
throw new Error('Missing deposit address in quote response');
|
|
@@ -200,6 +220,21 @@ const getTradeQuote = async (input, deps) => {
|
|
|
200
220
|
});
|
|
201
221
|
return { networkFeeCryptoBaseUnit: feeData.fast.txFee };
|
|
202
222
|
}
|
|
223
|
+
case caip_1.CHAIN_NAMESPACE.Ton: {
|
|
224
|
+
const sellAdapter = deps.assertGetTonChainAdapter(sellAsset.chainId);
|
|
225
|
+
const contractAddress = (0, utils_1.isToken)(sellAsset.assetId)
|
|
226
|
+
? (0, caip_1.fromAssetId)(sellAsset.assetId).assetReference
|
|
227
|
+
: undefined;
|
|
228
|
+
const feeData = await sellAdapter.getFeeData({
|
|
229
|
+
to: depositAddress,
|
|
230
|
+
value: sellAmount,
|
|
231
|
+
chainSpecific: {
|
|
232
|
+
from,
|
|
233
|
+
contractAddress,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
return { networkFeeCryptoBaseUnit: feeData.fast.txFee };
|
|
237
|
+
}
|
|
203
238
|
default:
|
|
204
239
|
throw new Error(`Unsupported chain namespace: ${chainNamespace}`);
|
|
205
240
|
}
|
|
@@ -64,7 +64,27 @@ const getTradeRate = async (input, deps) => {
|
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
66
|
};
|
|
67
|
-
const
|
|
67
|
+
const maxRetries = 3;
|
|
68
|
+
let quoteResponse = null;
|
|
69
|
+
let lastError = null;
|
|
70
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
71
|
+
try {
|
|
72
|
+
quoteResponse = await oneClickService_1.OneClickService.getQuote(quoteRequest);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
77
|
+
const isWebSocketError = lastError.message.includes('WebSocket is not ready');
|
|
78
|
+
if (isWebSocketError && attempt < maxRetries) {
|
|
79
|
+
await new Promise(resolve => setTimeout(resolve, 1000 * attempt));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
throw lastError;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!quoteResponse) {
|
|
86
|
+
throw lastError ?? new Error('Failed to get quote after retries');
|
|
87
|
+
}
|
|
68
88
|
const { quote } = quoteResponse;
|
|
69
89
|
if (!quote.depositAddress) {
|
|
70
90
|
throw new Error('Missing deposit address in quote response');
|
|
@@ -241,6 +261,46 @@ const getTradeRate = async (input, deps) => {
|
|
|
241
261
|
return '0';
|
|
242
262
|
}
|
|
243
263
|
}
|
|
264
|
+
case caip_1.CHAIN_NAMESPACE.Near: {
|
|
265
|
+
try {
|
|
266
|
+
const sellAdapter = deps.assertGetNearChainAdapter(sellAsset.chainId);
|
|
267
|
+
if (!sendAddress) {
|
|
268
|
+
return '0';
|
|
269
|
+
}
|
|
270
|
+
const feeData = await sellAdapter.getFeeData({
|
|
271
|
+
to: depositAddress,
|
|
272
|
+
value: sellAmount,
|
|
273
|
+
chainSpecific: { from: sendAddress },
|
|
274
|
+
});
|
|
275
|
+
return feeData.fast.txFee;
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
return '0';
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
case caip_1.CHAIN_NAMESPACE.Ton: {
|
|
282
|
+
try {
|
|
283
|
+
const sellAdapter = deps.assertGetTonChainAdapter(sellAsset.chainId);
|
|
284
|
+
const contractAddress = (0, utils_1.isToken)(sellAsset.assetId)
|
|
285
|
+
? (0, caip_1.fromAssetId)(sellAsset.assetId).assetReference
|
|
286
|
+
: undefined;
|
|
287
|
+
if (!sendAddress) {
|
|
288
|
+
return '0';
|
|
289
|
+
}
|
|
290
|
+
const feeData = await sellAdapter.getFeeData({
|
|
291
|
+
to: depositAddress,
|
|
292
|
+
value: sellAmount,
|
|
293
|
+
chainSpecific: {
|
|
294
|
+
from: sendAddress,
|
|
295
|
+
contractAddress,
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
return feeData.fast.txFee;
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
return '0';
|
|
302
|
+
}
|
|
303
|
+
}
|
|
244
304
|
default:
|
|
245
305
|
return undefined;
|
|
246
306
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
2
|
export { QuoteRequest } from '@defuse-protocol/one-click-sdk-typescript';
|
|
3
3
|
export type { GetExecutionStatusResponse, QuoteResponse, TokenResponse, } from '@defuse-protocol/one-click-sdk-typescript';
|
|
4
|
-
export declare const nearIntentsSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.GnosisMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BitcoinMainnet, KnownChainIds.DogecoinMainnet, KnownChainIds.ZcashMainnet, KnownChainIds.SolanaMainnet, KnownChainIds.TronMainnet, KnownChainIds.SuiMainnet, KnownChainIds.StarknetMainnet, KnownChainIds.MonadMainnet, KnownChainIds.NearMainnet];
|
|
4
|
+
export declare const nearIntentsSupportedChainIds: readonly [KnownChainIds.EthereumMainnet, KnownChainIds.ArbitrumMainnet, KnownChainIds.BaseMainnet, KnownChainIds.GnosisMainnet, KnownChainIds.BnbSmartChainMainnet, KnownChainIds.PolygonMainnet, KnownChainIds.AvalancheMainnet, KnownChainIds.OptimismMainnet, KnownChainIds.BitcoinMainnet, KnownChainIds.BitcoinCashMainnet, KnownChainIds.DogecoinMainnet, KnownChainIds.ZcashMainnet, KnownChainIds.SolanaMainnet, KnownChainIds.TronMainnet, KnownChainIds.SuiMainnet, KnownChainIds.StarknetMainnet, KnownChainIds.MonadMainnet, KnownChainIds.NearMainnet, KnownChainIds.PlasmaMainnet, KnownChainIds.TonMainnet];
|
|
5
5
|
export type NearIntentsSupportedChainId = (typeof nearIntentsSupportedChainIds)[number];
|
|
6
6
|
export declare const chainIdToNearIntentsChain: Record<NearIntentsSupportedChainId, string>;
|
|
@@ -14,6 +14,7 @@ exports.nearIntentsSupportedChainIds = [
|
|
|
14
14
|
types_1.KnownChainIds.AvalancheMainnet,
|
|
15
15
|
types_1.KnownChainIds.OptimismMainnet,
|
|
16
16
|
types_1.KnownChainIds.BitcoinMainnet,
|
|
17
|
+
types_1.KnownChainIds.BitcoinCashMainnet,
|
|
17
18
|
types_1.KnownChainIds.DogecoinMainnet,
|
|
18
19
|
types_1.KnownChainIds.ZcashMainnet,
|
|
19
20
|
types_1.KnownChainIds.SolanaMainnet,
|
|
@@ -22,6 +23,8 @@ exports.nearIntentsSupportedChainIds = [
|
|
|
22
23
|
types_1.KnownChainIds.StarknetMainnet,
|
|
23
24
|
types_1.KnownChainIds.MonadMainnet,
|
|
24
25
|
types_1.KnownChainIds.NearMainnet,
|
|
26
|
+
types_1.KnownChainIds.PlasmaMainnet,
|
|
27
|
+
types_1.KnownChainIds.TonMainnet,
|
|
25
28
|
];
|
|
26
29
|
exports.chainIdToNearIntentsChain = {
|
|
27
30
|
[types_1.KnownChainIds.EthereumMainnet]: 'eth',
|
|
@@ -33,12 +36,15 @@ exports.chainIdToNearIntentsChain = {
|
|
|
33
36
|
[types_1.KnownChainIds.AvalancheMainnet]: 'avax',
|
|
34
37
|
[types_1.KnownChainIds.OptimismMainnet]: 'op',
|
|
35
38
|
[types_1.KnownChainIds.BitcoinMainnet]: 'btc',
|
|
39
|
+
[types_1.KnownChainIds.BitcoinCashMainnet]: 'bch',
|
|
36
40
|
[types_1.KnownChainIds.DogecoinMainnet]: 'doge',
|
|
37
41
|
[types_1.KnownChainIds.ZcashMainnet]: 'zec',
|
|
42
|
+
[types_1.KnownChainIds.PlasmaMainnet]: 'plasma',
|
|
38
43
|
[types_1.KnownChainIds.SolanaMainnet]: 'sol',
|
|
39
44
|
[types_1.KnownChainIds.TronMainnet]: 'tron',
|
|
40
45
|
[types_1.KnownChainIds.SuiMainnet]: 'sui',
|
|
41
46
|
[types_1.KnownChainIds.StarknetMainnet]: 'starknet',
|
|
42
47
|
[types_1.KnownChainIds.MonadMainnet]: 'monad',
|
|
43
48
|
[types_1.KnownChainIds.NearMainnet]: 'near',
|
|
49
|
+
[types_1.KnownChainIds.TonMainnet]: 'ton',
|
|
44
50
|
};
|
|
@@ -8,6 +8,25 @@ const utils_1 = require("@shapeshiftoss/utils");
|
|
|
8
8
|
const viem_1 = require("viem");
|
|
9
9
|
const types_1 = require("../../types");
|
|
10
10
|
const oneClickService_1 = require("../oneClickService");
|
|
11
|
+
const getTokensWithRetry = async () => {
|
|
12
|
+
const maxRetries = 3;
|
|
13
|
+
let lastError = null;
|
|
14
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
15
|
+
try {
|
|
16
|
+
return await oneClickService_1.OneClickService.getTokens();
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
20
|
+
const isWebSocketError = lastError.message.includes('WebSocket is not ready');
|
|
21
|
+
if (isWebSocketError && attempt < maxRetries) {
|
|
22
|
+
await new Promise(resolve => setTimeout(resolve, 1000 * attempt));
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
throw lastError;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
throw lastError ?? new Error('Failed to get tokens after retries');
|
|
29
|
+
};
|
|
11
30
|
const ATA_RENT_LAMPORTS = 2040000;
|
|
12
31
|
const calculateAccountCreationCosts = (instructions) => {
|
|
13
32
|
let totalCost = (0, utils_1.bnOrZero)(0);
|
|
@@ -28,8 +47,8 @@ const getNearIntentsAsset = ({ nearNetwork, contractAddress, }) => {
|
|
|
28
47
|
return `nep141:${nearNetwork}-${contractAddress.toLowerCase()}.omft.near`;
|
|
29
48
|
};
|
|
30
49
|
exports.getNearIntentsAsset = getNearIntentsAsset;
|
|
31
|
-
const NEP245_CHAINS = ['bsc', 'pol', 'avax', 'op', 'tron', 'monad'];
|
|
32
|
-
const TOKEN_LOOKUP_CHAINS = ['sui', 'starknet'];
|
|
50
|
+
const NEP245_CHAINS = ['bsc', 'pol', 'avax', 'op', 'tron', 'monad', 'plasma'];
|
|
51
|
+
const TOKEN_LOOKUP_CHAINS = ['sui', 'starknet', 'ton'];
|
|
33
52
|
const NEAR_CHAIN = 'near';
|
|
34
53
|
const WNEAR_CONTRACT_ADDRESS = 'wrap.near';
|
|
35
54
|
const isNep245Chain = (chain) => {
|
|
@@ -45,7 +64,7 @@ const assetToNearIntentsAsset = async (asset) => {
|
|
|
45
64
|
// NEAR chain requires special handling
|
|
46
65
|
// Native NEAR maps to wNEAR (wrap.near)
|
|
47
66
|
if (nearNetwork === NEAR_CHAIN) {
|
|
48
|
-
const tokens = await
|
|
67
|
+
const tokens = await getTokensWithRetry();
|
|
49
68
|
const { assetNamespace, assetReference } = (0, caip_1.fromAssetId)(asset.assetId);
|
|
50
69
|
const isNativeAsset = assetNamespace === 'slip44';
|
|
51
70
|
// Native NEAR maps to wNEAR, tokens use their contract address directly
|
|
@@ -61,7 +80,7 @@ const assetToNearIntentsAsset = async (asset) => {
|
|
|
61
80
|
// Asset IDs use hashed format that can't be generated from contract addresses
|
|
62
81
|
const requiresLookup = isNep245Chain(nearNetwork) || isTokenLookupChain(nearNetwork) || asset.chainId === caip_1.solanaChainId;
|
|
63
82
|
if (requiresLookup) {
|
|
64
|
-
const tokens = await
|
|
83
|
+
const tokens = await getTokensWithRetry();
|
|
65
84
|
const { assetNamespace, assetReference } = (0, caip_1.fromAssetId)(asset.assetId);
|
|
66
85
|
const isNativeAsset = assetNamespace === 'slip44';
|
|
67
86
|
const contractAddress = !isNativeAsset ? assetReference.toLowerCase() : null;
|
|
@@ -17,7 +17,6 @@ const fetchPortalsTradeOrder_1 = require("../utils/fetchPortalsTradeOrder");
|
|
|
17
17
|
const helpers_2 = require("../utils/helpers");
|
|
18
18
|
async function getPortalsTradeRate(input, assertGetEvmChainAdapter, swapperConfig) {
|
|
19
19
|
const { sellAsset, buyAsset, accountNumber, affiliateBps, chainId, sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, supportsEIP1559, } = input;
|
|
20
|
-
const adapter = assertGetEvmChainAdapter(chainId);
|
|
21
20
|
const sellAssetChainId = sellAsset.chainId;
|
|
22
21
|
const buyAssetChainId = buyAsset.chainId;
|
|
23
22
|
if (!(0, helpers_2.isSupportedChainId)(sellAssetChainId)) {
|
|
@@ -34,10 +33,16 @@ async function getPortalsTradeRate(input, assertGetEvmChainAdapter, swapperConfi
|
|
|
34
33
|
details: { chainId: sellAsset.chainId },
|
|
35
34
|
}));
|
|
36
35
|
}
|
|
36
|
+
if (!(0, helpers_2.isSupportedChainId)(chainId)) {
|
|
37
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
38
|
+
message: `unsupported chainId`,
|
|
39
|
+
code: types_1.TradeQuoteError.UnsupportedChain,
|
|
40
|
+
details: { chainId },
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
const adapter = assertGetEvmChainAdapter(chainId);
|
|
37
44
|
const isCrossChain = sellAssetChainId !== buyAssetChainId;
|
|
38
45
|
try {
|
|
39
|
-
if (!(0, helpers_2.isSupportedChainId)(chainId))
|
|
40
|
-
throw new Error(`Unsupported chainId ${sellAsset.chainId}`);
|
|
41
46
|
const sellPortalsNetwork = constants_1.chainIdToPortalsNetwork[sellAssetChainId];
|
|
42
47
|
const buyPortalsNetwork = constants_1.chainIdToPortalsNetwork[buyAssetChainId];
|
|
43
48
|
if (!sellPortalsNetwork) {
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.relayErrorCodeToTradeQuoteError = exports.MAXIMUM_SUPPORTED_RELAY_STEPS = exports.DEFAULT_RELAY_TRON_USER_ADDRESS = exports.DEFAULT_RELAY_SOLANA_USER_ADDRESS = exports.DEFAULT_RELAY_BTC_USER_ADDRESS = exports.DEFAULT_RELAY_EVM_USER_ADDRESS = exports.RELAY_TRON_TOKEN_ADDRESS = exports.RELAY_SOLANA_TOKEN_ADDRESS = exports.RELAY_BTC_TOKEN_ADDRESS = exports.DEFAULT_RELAY_EVM_TOKEN_ADDRESS = exports.relayChainIdToChainId = exports.RelayStatusMessage = exports.chainIdToRelayChainId = void 0;
|
|
7
7
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
|
+
const contracts_1 = require("@shapeshiftoss/contracts");
|
|
8
9
|
const invert_1 = __importDefault(require("lodash/invert"));
|
|
9
10
|
const viem_1 = require("viem");
|
|
10
11
|
const chains_1 = require("viem/chains");
|
|
@@ -23,11 +24,35 @@ exports.chainIdToRelayChainId = {
|
|
|
23
24
|
[caip_1.gnosisChainId]: chains_1.gnosis.id,
|
|
24
25
|
[caip_1.avalancheChainId]: chains_1.avalanche.id,
|
|
25
26
|
[caip_1.bscChainId]: chains_1.bsc.id,
|
|
26
|
-
|
|
27
|
+
// DISABLED: Tron deposits are built as simple TRC20 transfers instead of depositErc20() vault calls,
|
|
28
|
+
// and the Relay indexer notification is never sent for non-EVM chains. This causes deposits to be
|
|
29
|
+
// untracked by Relay, resulting in stuck/lost funds. Re-enable once the Tron transaction building
|
|
30
|
+
// is verified to use the Relay quote calldata (depositErc20) correctly.
|
|
31
|
+
// [tronChainId]: 728126428,
|
|
27
32
|
[caip_1.monadChainId]: chains_1.monad.id,
|
|
28
33
|
[caip_1.hyperEvmChainId]: chains_1.hyperEvm.id,
|
|
34
|
+
[caip_1.mantleChainId]: chains_1.mantle.id,
|
|
35
|
+
[caip_1.inkChainId]: chains_1.ink.id,
|
|
36
|
+
[caip_1.megaethChainId]: 4326,
|
|
29
37
|
[caip_1.plasmaChainId]: chains_1.plasma.id,
|
|
38
|
+
[caip_1.plumeChainId]: chains_1.plumeMainnet.id,
|
|
30
39
|
[caip_1.katanaChainId]: chains_1.katana.id,
|
|
40
|
+
[caip_1.flowEvmChainId]: contracts_1.flowEvmChain.id,
|
|
41
|
+
[caip_1.celoChainId]: chains_1.celo.id,
|
|
42
|
+
[caip_1.storyChainId]: chains_1.story.id,
|
|
43
|
+
[caip_1.zkSyncEraChainId]: chains_1.zksync.id,
|
|
44
|
+
[caip_1.blastChainId]: chains_1.blast.id,
|
|
45
|
+
[caip_1.worldChainChainId]: chains_1.worldchain.id,
|
|
46
|
+
[caip_1.hemiChainId]: chains_1.hemi.id,
|
|
47
|
+
[caip_1.lineaChainId]: chains_1.linea.id,
|
|
48
|
+
[caip_1.berachainChainId]: chains_1.berachain.id,
|
|
49
|
+
[caip_1.scrollChainId]: chains_1.scroll.id,
|
|
50
|
+
[caip_1.cronosChainId]: chains_1.cronos.id,
|
|
51
|
+
[caip_1.sonicChainId]: chains_1.sonic.id,
|
|
52
|
+
[caip_1.unichainChainId]: chains_1.unichain.id,
|
|
53
|
+
[caip_1.bobChainId]: chains_1.bob.id,
|
|
54
|
+
[caip_1.modeChainId]: chains_1.mode.id,
|
|
55
|
+
[caip_1.soneiumChainId]: chains_1.soneium.id,
|
|
31
56
|
};
|
|
32
57
|
var RelayStatusMessage;
|
|
33
58
|
(function (RelayStatusMessage) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
export declare const getRelayDefaultUserAddress: (chainId: ChainId) => "0x000000000000000000000000000000000000dead" | "
|
|
2
|
+
export declare const getRelayDefaultUserAddress: (chainId: ChainId) => "0x000000000000000000000000000000000000dead" | "CbKGgVKLJFb8bBrf58DnAkdryX6ubewVytn7X957YwNr" | "bc1q4vxn43l44h30nkluqfxd9eckf45vr2awz38lwa" | "TLsV52sRDL79HXGGm9yzwKibb6BeruhUzy";
|
|
@@ -142,6 +142,13 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
142
142
|
}));
|
|
143
143
|
}
|
|
144
144
|
const { data: quote } = maybeQuote.unwrap();
|
|
145
|
+
const orderId = quote.protocol?.v2?.orderId;
|
|
146
|
+
if (!orderId && sellAsset.chainId === caip_1.btcChainId) {
|
|
147
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
148
|
+
message: 'Relay quote missing protocol.v2.orderId',
|
|
149
|
+
code: types_1.TradeQuoteError.UnknownError,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
145
152
|
const { slippageTolerance, currencyOut, timeEstimate } = quote.details;
|
|
146
153
|
const buyAmountAfterFeesCryptoBaseUnit = currencyOut.amount;
|
|
147
154
|
const rate = (0, utils_2.getInputOutputRate)({
|
|
@@ -336,7 +343,7 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
336
343
|
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
337
344
|
chainSpecific: {
|
|
338
345
|
pubkey: xpub ?? (0, getRelayDefaultUserAddress_1.getRelayDefaultUserAddress)(sellAsset.chainId),
|
|
339
|
-
opReturnData:
|
|
346
|
+
opReturnData: orderId,
|
|
340
347
|
},
|
|
341
348
|
sendMax: false,
|
|
342
349
|
};
|
|
@@ -411,9 +418,10 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
411
418
|
relayTransactionMetadata: {
|
|
412
419
|
from: sendAddress,
|
|
413
420
|
psbt: selectedItem.data.psbt,
|
|
414
|
-
opReturnData:
|
|
421
|
+
opReturnData: orderId,
|
|
415
422
|
to: relayer,
|
|
416
423
|
relayId: quote.steps[0].requestId,
|
|
424
|
+
orderId,
|
|
417
425
|
},
|
|
418
426
|
solanaTransactionMetadata: undefined,
|
|
419
427
|
};
|
|
@@ -431,6 +439,7 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
431
439
|
gasLimit: selectedItem.data?.gas,
|
|
432
440
|
chainId: Number((0, caip_1.fromChainId)(sellAsset.chainId).chainReference),
|
|
433
441
|
relayId: quote.steps[0].requestId,
|
|
442
|
+
orderId,
|
|
434
443
|
},
|
|
435
444
|
solanaTransactionMetadata: undefined,
|
|
436
445
|
};
|
|
@@ -444,6 +453,7 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
444
453
|
},
|
|
445
454
|
relayTransactionMetadata: {
|
|
446
455
|
relayId: quote.steps[0].requestId,
|
|
456
|
+
orderId,
|
|
447
457
|
},
|
|
448
458
|
};
|
|
449
459
|
}
|
|
@@ -453,6 +463,7 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
453
463
|
solanaTransactionMetadata: undefined,
|
|
454
464
|
relayTransactionMetadata: {
|
|
455
465
|
relayId: quote.steps[0].requestId,
|
|
466
|
+
orderId,
|
|
456
467
|
to: selectedItem.data?.parameter?.contract_address,
|
|
457
468
|
},
|
|
458
469
|
};
|
|
@@ -112,11 +112,111 @@ const relayTokenToAssetId = (relayToken) => {
|
|
|
112
112
|
assetReference: caip_1.ASSET_REFERENCE.Plasma,
|
|
113
113
|
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
114
114
|
};
|
|
115
|
+
case caip_1.CHAIN_REFERENCE.PlumeMainnet:
|
|
116
|
+
return {
|
|
117
|
+
assetReference: caip_1.ASSET_REFERENCE.Plume,
|
|
118
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
119
|
+
};
|
|
120
|
+
case caip_1.CHAIN_REFERENCE.MantleMainnet:
|
|
121
|
+
return {
|
|
122
|
+
assetReference: caip_1.ASSET_REFERENCE.Mantle,
|
|
123
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
124
|
+
};
|
|
125
|
+
case caip_1.CHAIN_REFERENCE.InkMainnet:
|
|
126
|
+
return {
|
|
127
|
+
assetReference: caip_1.ASSET_REFERENCE.Ink,
|
|
128
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
129
|
+
};
|
|
130
|
+
case caip_1.CHAIN_REFERENCE.MegaEthMainnet:
|
|
131
|
+
return {
|
|
132
|
+
assetReference: caip_1.ASSET_REFERENCE.MegaEth,
|
|
133
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
134
|
+
};
|
|
135
|
+
case caip_1.CHAIN_REFERENCE.BerachainMainnet:
|
|
136
|
+
return {
|
|
137
|
+
assetReference: caip_1.ASSET_REFERENCE.Berachain,
|
|
138
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
139
|
+
};
|
|
115
140
|
case caip_1.CHAIN_REFERENCE.KatanaMainnet:
|
|
116
141
|
return {
|
|
117
142
|
assetReference: caip_1.ASSET_REFERENCE.Katana,
|
|
118
143
|
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
119
144
|
};
|
|
145
|
+
case caip_1.CHAIN_REFERENCE.FlowEvmMainnet:
|
|
146
|
+
return {
|
|
147
|
+
assetReference: caip_1.ASSET_REFERENCE.FlowEvm,
|
|
148
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
149
|
+
};
|
|
150
|
+
case caip_1.CHAIN_REFERENCE.CeloMainnet:
|
|
151
|
+
return {
|
|
152
|
+
assetReference: caip_1.ASSET_REFERENCE.Celo,
|
|
153
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
154
|
+
};
|
|
155
|
+
case caip_1.CHAIN_REFERENCE.StoryMainnet:
|
|
156
|
+
return {
|
|
157
|
+
assetReference: caip_1.ASSET_REFERENCE.Story,
|
|
158
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
159
|
+
};
|
|
160
|
+
case caip_1.CHAIN_REFERENCE.ZkSyncEraMainnet:
|
|
161
|
+
return {
|
|
162
|
+
assetReference: caip_1.ASSET_REFERENCE.ZkSyncEra,
|
|
163
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
164
|
+
};
|
|
165
|
+
case caip_1.CHAIN_REFERENCE.BlastMainnet:
|
|
166
|
+
return {
|
|
167
|
+
assetReference: caip_1.ASSET_REFERENCE.Blast,
|
|
168
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
169
|
+
};
|
|
170
|
+
case caip_1.CHAIN_REFERENCE.WorldChainMainnet:
|
|
171
|
+
return {
|
|
172
|
+
assetReference: caip_1.ASSET_REFERENCE.WorldChain,
|
|
173
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
174
|
+
};
|
|
175
|
+
case caip_1.CHAIN_REFERENCE.HemiMainnet:
|
|
176
|
+
return {
|
|
177
|
+
assetReference: caip_1.ASSET_REFERENCE.Hemi,
|
|
178
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
179
|
+
};
|
|
180
|
+
case caip_1.CHAIN_REFERENCE.LineaMainnet:
|
|
181
|
+
return {
|
|
182
|
+
assetReference: caip_1.ASSET_REFERENCE.Linea,
|
|
183
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
184
|
+
};
|
|
185
|
+
case caip_1.CHAIN_REFERENCE.ScrollMainnet:
|
|
186
|
+
return {
|
|
187
|
+
assetReference: caip_1.ASSET_REFERENCE.Scroll,
|
|
188
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
189
|
+
};
|
|
190
|
+
case caip_1.CHAIN_REFERENCE.CronosMainnet:
|
|
191
|
+
return {
|
|
192
|
+
assetReference: caip_1.ASSET_REFERENCE.Cronos,
|
|
193
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
194
|
+
};
|
|
195
|
+
case caip_1.CHAIN_REFERENCE.SonicMainnet:
|
|
196
|
+
return {
|
|
197
|
+
assetReference: caip_1.ASSET_REFERENCE.Sonic,
|
|
198
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
199
|
+
};
|
|
200
|
+
case caip_1.CHAIN_REFERENCE.UnichainMainnet:
|
|
201
|
+
return {
|
|
202
|
+
assetReference: caip_1.ASSET_REFERENCE.Unichain,
|
|
203
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
204
|
+
};
|
|
205
|
+
case caip_1.CHAIN_REFERENCE.BobMainnet:
|
|
206
|
+
return {
|
|
207
|
+
assetReference: caip_1.ASSET_REFERENCE.Bob,
|
|
208
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
209
|
+
};
|
|
210
|
+
case caip_1.CHAIN_REFERENCE.ModeMainnet:
|
|
211
|
+
return {
|
|
212
|
+
assetReference: caip_1.ASSET_REFERENCE.Mode,
|
|
213
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
214
|
+
};
|
|
215
|
+
case caip_1.CHAIN_REFERENCE.SoneiumMainnet:
|
|
216
|
+
return {
|
|
217
|
+
assetReference: caip_1.ASSET_REFERENCE.Soneium,
|
|
218
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
219
|
+
};
|
|
120
220
|
default:
|
|
121
221
|
throw Error(`chainId '${relayToken.chainId}' not supported`);
|
|
122
222
|
}
|
|
@@ -22,6 +22,7 @@ export type RelayTransactionMetadata = {
|
|
|
22
22
|
psbt?: string;
|
|
23
23
|
opReturnData?: string;
|
|
24
24
|
relayId: string;
|
|
25
|
+
orderId: string | undefined;
|
|
25
26
|
};
|
|
26
27
|
export type RelayStatus = {
|
|
27
28
|
status: 'success' | 'failed' | 'pending' | 'refund' | 'delayed' | 'waiting';
|
|
@@ -120,10 +121,24 @@ export type RelayQuoteStep = {
|
|
|
120
121
|
requestId: string;
|
|
121
122
|
items?: RelayQuoteItem[];
|
|
122
123
|
};
|
|
124
|
+
export type RelayProtocolV2 = {
|
|
125
|
+
orderId: string | undefined;
|
|
126
|
+
orderData?: unknown;
|
|
127
|
+
paymentDetails?: {
|
|
128
|
+
chainId: string;
|
|
129
|
+
depository: string;
|
|
130
|
+
currency: string;
|
|
131
|
+
amount: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export type RelayProtocol = {
|
|
135
|
+
v2?: RelayProtocolV2;
|
|
136
|
+
};
|
|
123
137
|
export type RelayQuote = {
|
|
124
138
|
fees: RelayFees;
|
|
125
139
|
details: QuoteDetails;
|
|
126
140
|
steps: RelayQuoteStep[];
|
|
141
|
+
protocol?: RelayProtocol;
|
|
127
142
|
};
|
|
128
143
|
export declare const isRelayQuoteUtxoItemData: (item: RelayQuoteUtxoItemData | RelayQuoteEvmItemData | RelayQuoteSolanaItemData | RelayQuoteTronItemData) => item is RelayQuoteUtxoItemData;
|
|
129
144
|
export declare const isRelayQuoteEvmItemData: (item: RelayQuoteUtxoItemData | RelayQuoteEvmItemData | RelayQuoteSolanaItemData | RelayQuoteTronItemData) => item is RelayQuoteEvmItemData;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stonfiSwapper = void 0;
|
|
4
|
+
exports.stonfiSwapper = {
|
|
5
|
+
executeTonTransaction: (txToSign, { signAndBroadcastTransaction }) => {
|
|
6
|
+
return signAndBroadcastTransaction(txToSign);
|
|
7
|
+
},
|
|
8
|
+
};
|