@shapeshiftoss/swapper 17.6.9 → 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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForQuote = exports.affiliateBpsToNumber = exports.tonAddressToOmnistonAddress = exports.slippageDecimalToBps = exports.calculateRate = exports.validateTonAssets = exports.assetToOmnistonAddress = exports.isTonAsset = void 0;
|
|
4
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
+
const types_1 = require("@shapeshiftoss/types");
|
|
6
|
+
const utils_1 = require("@shapeshiftoss/utils");
|
|
7
|
+
const monads_1 = require("@sniptt/monads");
|
|
8
|
+
const omniston_sdk_1 = require("@ston-fi/omniston-sdk");
|
|
9
|
+
const types_2 = require("../../../types");
|
|
10
|
+
const utils_2 = require("../../../utils");
|
|
11
|
+
const isTonAsset = (asset) => {
|
|
12
|
+
return asset.chainId === types_1.KnownChainIds.TonMainnet;
|
|
13
|
+
};
|
|
14
|
+
exports.isTonAsset = isTonAsset;
|
|
15
|
+
const assetToOmnistonAddress = (asset) => {
|
|
16
|
+
if (!(0, exports.isTonAsset)(asset))
|
|
17
|
+
return null;
|
|
18
|
+
const { assetNamespace, assetReference } = (0, caip_1.fromAssetId)(asset.assetId);
|
|
19
|
+
if (assetNamespace === 'slip44') {
|
|
20
|
+
return {
|
|
21
|
+
blockchain: omniston_sdk_1.Blockchain.TON,
|
|
22
|
+
address: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (assetNamespace === 'jetton') {
|
|
26
|
+
return { blockchain: omniston_sdk_1.Blockchain.TON, address: assetReference };
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
exports.assetToOmnistonAddress = assetToOmnistonAddress;
|
|
31
|
+
const validateTonAssets = (sellAsset, buyAsset) => {
|
|
32
|
+
if (sellAsset.chainId !== types_1.KnownChainIds.TonMainnet) {
|
|
33
|
+
return {
|
|
34
|
+
isValid: false,
|
|
35
|
+
error: (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
36
|
+
message: `[Stonfi] Unsupported sell asset chain: ${sellAsset.chainId}`,
|
|
37
|
+
code: types_2.TradeQuoteError.UnsupportedChain,
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (buyAsset.chainId !== types_1.KnownChainIds.TonMainnet) {
|
|
42
|
+
return {
|
|
43
|
+
isValid: false,
|
|
44
|
+
error: (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
45
|
+
message: `[Stonfi] Cross-chain swaps not supported`,
|
|
46
|
+
code: types_2.TradeQuoteError.CrossChainNotSupported,
|
|
47
|
+
})),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const bidAssetAddress = (0, exports.assetToOmnistonAddress)(sellAsset);
|
|
51
|
+
const askAssetAddress = (0, exports.assetToOmnistonAddress)(buyAsset);
|
|
52
|
+
if (!bidAssetAddress || !askAssetAddress) {
|
|
53
|
+
return {
|
|
54
|
+
isValid: false,
|
|
55
|
+
error: (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
56
|
+
message: `[Stonfi] Unable to convert assets to Omniston addresses`,
|
|
57
|
+
code: types_2.TradeQuoteError.UnsupportedTradePair,
|
|
58
|
+
})),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
isValid: true,
|
|
63
|
+
bidAssetAddress,
|
|
64
|
+
askAssetAddress,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.validateTonAssets = validateTonAssets;
|
|
68
|
+
const calculateRate = (buyAmountCryptoBaseUnit, sellAmountCryptoBaseUnit, buyAssetPrecision, sellAssetPrecision) => {
|
|
69
|
+
if ((0, utils_1.bn)(buyAmountCryptoBaseUnit).gt(0) && (0, utils_1.bn)(sellAmountCryptoBaseUnit).gt(0)) {
|
|
70
|
+
return (0, utils_1.convertPrecision)({
|
|
71
|
+
value: buyAmountCryptoBaseUnit,
|
|
72
|
+
inputExponent: buyAssetPrecision,
|
|
73
|
+
outputExponent: sellAssetPrecision,
|
|
74
|
+
})
|
|
75
|
+
.dividedBy((0, utils_1.bn)(sellAmountCryptoBaseUnit))
|
|
76
|
+
.toFixed();
|
|
77
|
+
}
|
|
78
|
+
return '0';
|
|
79
|
+
};
|
|
80
|
+
exports.calculateRate = calculateRate;
|
|
81
|
+
const slippageDecimalToBps = (slippageTolerancePercentageDecimal, defaultSlippageBps) => {
|
|
82
|
+
if (!slippageTolerancePercentageDecimal) {
|
|
83
|
+
return defaultSlippageBps;
|
|
84
|
+
}
|
|
85
|
+
const parsed = parseFloat(slippageTolerancePercentageDecimal);
|
|
86
|
+
if (Number.isNaN(parsed) || !Number.isFinite(parsed) || parsed < 0) {
|
|
87
|
+
return defaultSlippageBps;
|
|
88
|
+
}
|
|
89
|
+
return Math.round(parsed * 10000);
|
|
90
|
+
};
|
|
91
|
+
exports.slippageDecimalToBps = slippageDecimalToBps;
|
|
92
|
+
const tonAddressToOmnistonAddress = (address) => {
|
|
93
|
+
return {
|
|
94
|
+
blockchain: omniston_sdk_1.Blockchain.TON,
|
|
95
|
+
address,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.tonAddressToOmnistonAddress = tonAddressToOmnistonAddress;
|
|
99
|
+
const affiliateBpsToNumber = (affiliateBps) => {
|
|
100
|
+
if (!affiliateBps)
|
|
101
|
+
return 0;
|
|
102
|
+
const parsed = parseInt(affiliateBps, 10);
|
|
103
|
+
if (Number.isNaN(parsed) || !Number.isFinite(parsed) || parsed < 0)
|
|
104
|
+
return 0;
|
|
105
|
+
return parsed;
|
|
106
|
+
};
|
|
107
|
+
exports.affiliateBpsToNumber = affiliateBpsToNumber;
|
|
108
|
+
const waitForQuote = (omniston, request, timeoutMs) => {
|
|
109
|
+
return new Promise(resolve => {
|
|
110
|
+
const timer = setTimeout(() => {
|
|
111
|
+
subscription.unsubscribe();
|
|
112
|
+
resolve({ type: 'timeout' });
|
|
113
|
+
}, timeoutMs);
|
|
114
|
+
const subscription = omniston.requestForQuote(request).subscribe({
|
|
115
|
+
next: (event) => {
|
|
116
|
+
if (event.type === 'quoteUpdated' && event.quote) {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
subscription.unsubscribe();
|
|
119
|
+
resolve({ type: 'success', quote: event.quote });
|
|
120
|
+
}
|
|
121
|
+
else if (event.type === 'noQuote') {
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
subscription.unsubscribe();
|
|
124
|
+
resolve({ type: 'noQuote' });
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
error: err => {
|
|
128
|
+
clearTimeout(timer);
|
|
129
|
+
subscription.unsubscribe();
|
|
130
|
+
resolve({ type: 'error', error: err });
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
exports.waitForQuote = waitForQuote;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.omnistonManager = void 0;
|
|
4
|
+
const omniston_sdk_1 = require("@ston-fi/omniston-sdk");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
let cachedOmniston = null;
|
|
7
|
+
exports.omnistonManager = {
|
|
8
|
+
getInstance: () => {
|
|
9
|
+
if (!cachedOmniston) {
|
|
10
|
+
cachedOmniston = new omniston_sdk_1.Omniston({ apiUrl: constants_1.STONFI_WEBSOCKET_URL });
|
|
11
|
+
}
|
|
12
|
+
return cachedOmniston;
|
|
13
|
+
},
|
|
14
|
+
disconnect: () => {
|
|
15
|
+
if (cachedOmniston) {
|
|
16
|
+
cachedOmniston.close();
|
|
17
|
+
cachedOmniston = null;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -46,7 +46,7 @@ exports.sunioApi = {
|
|
|
46
46
|
const tronWeb = new tronweb_1.TronWeb({
|
|
47
47
|
fullHost: rpcUrl,
|
|
48
48
|
});
|
|
49
|
-
const routeParams = (0, buildSwapRouteParameters_1.buildSwapRouteParameters)(sunioMetadata.route, step.sellAmountIncludingProtocolFeesCryptoBaseUnit, step.buyAmountAfterFeesCryptoBaseUnit,
|
|
49
|
+
const routeParams = (0, buildSwapRouteParameters_1.buildSwapRouteParameters)(sunioMetadata.route, step.sellAmountIncludingProtocolFeesCryptoBaseUnit, step.buyAmountAfterFeesCryptoBaseUnit, tradeQuote.receiveAddress, slippageTolerancePercentageDecimal);
|
|
50
50
|
const parameters = [
|
|
51
51
|
{ type: 'address[]', value: routeParams.path },
|
|
52
52
|
{ type: 'string[]', value: routeParams.poolVersion },
|
|
@@ -136,9 +136,10 @@ async function getQuoteOrRate(input, deps) {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const buyAmountCryptoBaseUnit =
|
|
140
|
-
.
|
|
141
|
-
.
|
|
139
|
+
const buyAmountCryptoBaseUnit = utils_1.BigAmount.fromPrecision({
|
|
140
|
+
value: bestRoute.amountOut,
|
|
141
|
+
precision: buyAsset.precision,
|
|
142
|
+
}).toBaseUnit();
|
|
142
143
|
// Calculate protocol fees only for quotes
|
|
143
144
|
const protocolFeeCryptoBaseUnit = isQuote
|
|
144
145
|
? (0, utils_1.bn)(bestRoute.fee).times(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0)
|
|
@@ -8,7 +8,7 @@ export declare const isSupportedChainId: (chainId: ChainId) => chainId is KnownC
|
|
|
8
8
|
export declare const assertValidTrade: ({ buyAsset, sellAsset, }: {
|
|
9
9
|
buyAsset: Asset;
|
|
10
10
|
sellAsset: Asset;
|
|
11
|
-
}) => import("@sniptt/monads/build/result/result").
|
|
11
|
+
}) => import("@sniptt/monads/build/result/result").ResErr<unknown, import("../../../../types").SwapErrorRight> | import("@sniptt/monads/build/result/result").ResOk<boolean, never>;
|
|
12
12
|
export declare const calculateRate: ({ buyAmount, sellAmount, buyAsset, sellAsset, }: {
|
|
13
13
|
buyAmount: string;
|
|
14
14
|
sellAmount: string;
|
package/dist/cjs/swappers/utils/filterBuyAssetsBySellAssetId/filterBuyAssetsBySellAssetId.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.filterCrossChainEvmBuyAssetsBySellAssetId = exports.filterSameChainEvmBuyAssetsBySellAssetId = void 0;
|
|
4
|
-
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
4
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
6
5
|
const _filterEvmBuyAssetsBySellAssetId = ({ assets, sellAsset }, chainIdPredicate) => {
|
|
7
6
|
// evm only
|
|
8
7
|
if (!(0, chain_adapters_1.isEvmChainId)(sellAsset.chainId))
|
|
9
8
|
return [];
|
|
10
9
|
return assets.filter(buyAsset => {
|
|
11
|
-
// evm only AND chain id predicate
|
|
12
|
-
return (
|
|
13
|
-
chainIdPredicate(buyAsset.chainId, sellAsset.chainId) &&
|
|
14
|
-
buyAsset.chainId !== caip_1.arbitrumNovaChainId);
|
|
10
|
+
// evm only AND chain id predicate
|
|
11
|
+
return (0, chain_adapters_1.isEvmChainId)(buyAsset.chainId) && chainIdPredicate(buyAsset.chainId, sellAsset.chainId);
|
|
15
12
|
});
|
|
16
13
|
};
|
|
17
14
|
const filterSameChainEvmBuyAssetsBySellAssetId = (input) => {
|
|
@@ -46,6 +46,9 @@ const DAO_TREASURY_BY_CHAIN_ID = {
|
|
|
46
46
|
[types_1.KnownChainIds.SolanaMainnet]: utils_1.DAO_TREASURY_SOLANA,
|
|
47
47
|
[types_1.KnownChainIds.BitcoinMainnet]: utils_1.DAO_TREASURY_BITCOIN,
|
|
48
48
|
[types_1.KnownChainIds.StarknetMainnet]: utils_1.DAO_TREASURY_STARKNET,
|
|
49
|
+
[types_1.KnownChainIds.TonMainnet]: utils_1.DAO_TREASURY_TON,
|
|
50
|
+
[types_1.KnownChainIds.MonadMainnet]: utils_1.DAO_TREASURY_MONAD,
|
|
51
|
+
[types_1.KnownChainIds.HyperEvmMainnet]: utils_1.DAO_TREASURY_HYPEREVM,
|
|
49
52
|
};
|
|
50
53
|
const getTreasuryAddressFromChainId = (chainId) => {
|
|
51
54
|
const maybeTreasuryChainId = (0, utils_1.isTreasuryChainId)(chainId) ? chainId : undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from '@shapeshiftoss/types';
|
|
2
2
|
import type { SwapperConfig, SwapperName } from '../types';
|
|
3
3
|
import type { ThorEvmTradeQuote } from './types';
|
|
4
|
-
export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "data" | "slippageTolerancePercentageDecimal" | "memo" | "
|
|
4
|
+
export declare const getCallDataFromQuote: ({ tradeType, data, sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit, memo: tcMemo, expiry, config, longtailData, slippageTolerancePercentageDecimal, vault, swapperName, }: Pick<ThorEvmTradeQuote, "data" | "slippageTolerancePercentageDecimal" | "memo" | "expiry" | "tradeType" | "aggregator" | "vault" | "longtailData"> & {
|
|
5
5
|
sellAmountIncludingProtocolFeesCryptoBaseUnit: string;
|
|
6
6
|
config: SwapperConfig;
|
|
7
7
|
sellAsset: Asset;
|
|
@@ -101,7 +101,13 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
101
101
|
: '0';
|
|
102
102
|
const getRouteBuyAmountBeforeFeesCryptoBaseUnit = (quote) => {
|
|
103
103
|
const buyAmountBeforeFeesCryptoThorPrecision = (0, utils_1.bn)(quote.expected_amount_out).plus(quote.fees.total);
|
|
104
|
-
return
|
|
104
|
+
return utils_1.BigAmount.fromPrecision({
|
|
105
|
+
value: utils_1.BigAmount.fromBaseUnit({
|
|
106
|
+
value: buyAmountBeforeFeesCryptoThorPrecision,
|
|
107
|
+
precision: buyAssetNativePrecision,
|
|
108
|
+
}).toPrecision(),
|
|
109
|
+
precision: buyAsset.precision,
|
|
110
|
+
}).toBaseUnit();
|
|
105
111
|
};
|
|
106
112
|
const getProtocolFees = (quote) => {
|
|
107
113
|
// Fees consist of liquidity, outbound, and affiliate fees
|
|
@@ -241,7 +247,11 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
241
247
|
const sellAdapter = assertGetUtxoChainAdapter(sellAsset.chainId);
|
|
242
248
|
const maybeRoutes = await Promise.allSettled(perRouteValues.map(async (route) => {
|
|
243
249
|
const memo = getMemo(route);
|
|
244
|
-
const { vault } = await utxo.getThorTxData({
|
|
250
|
+
const { vault } = await utxo.getThorTxData({
|
|
251
|
+
sellAsset,
|
|
252
|
+
config,
|
|
253
|
+
swapperName,
|
|
254
|
+
});
|
|
245
255
|
const feeData = await (async () => {
|
|
246
256
|
const protocolFees = getProtocolFees(route.quote);
|
|
247
257
|
// This is a rate without a wallet connected, so we can't get fees
|
|
@@ -310,9 +320,15 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
310
320
|
const { sellAsset, sellAmountIncludingProtocolFeesCryptoBaseUnit } = input;
|
|
311
321
|
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
312
322
|
// Get vault address
|
|
313
|
-
const { vault } = await tron.getThorTxData({
|
|
323
|
+
const { vault } = await tron.getThorTxData({
|
|
324
|
+
sellAsset,
|
|
325
|
+
config,
|
|
326
|
+
swapperName,
|
|
327
|
+
});
|
|
314
328
|
// Estimate fees using the receive address for accurate energy calculation
|
|
315
|
-
const tronWeb = new tronweb_1.TronWeb({
|
|
329
|
+
const tronWeb = new tronweb_1.TronWeb({
|
|
330
|
+
fullHost: deps.config.VITE_TRON_NODE_URL,
|
|
331
|
+
});
|
|
316
332
|
const params = await tronWeb.trx.getChainParameters();
|
|
317
333
|
const bandwidthPrice = params.find(p => p.key === 'getTransactionFee')?.value ?? 1000;
|
|
318
334
|
const energyPrice = params.find(p => p.key === 'getEnergyFee')?.value ?? 100;
|
|
@@ -322,7 +338,10 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
322
338
|
try {
|
|
323
339
|
const result = await tronWeb.transactionBuilder.triggerConstantContract(contractAddress, 'transfer(address,uint256)', {}, [
|
|
324
340
|
{ type: 'address', value: vault },
|
|
325
|
-
{
|
|
341
|
+
{
|
|
342
|
+
type: 'uint256',
|
|
343
|
+
value: sellAmountIncludingProtocolFeesCryptoBaseUnit,
|
|
344
|
+
},
|
|
326
345
|
], input.receiveAddress);
|
|
327
346
|
const energyUsed = result.energy_used ?? 65000;
|
|
328
347
|
const energyFee = energyUsed * energyPrice * 1.5; // 1.5x safety margin
|
|
@@ -387,6 +406,12 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
387
406
|
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
388
407
|
}));
|
|
389
408
|
}
|
|
409
|
+
case caip_1.CHAIN_NAMESPACE.Ton: {
|
|
410
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
411
|
+
message: 'TON is not supported',
|
|
412
|
+
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
390
415
|
default:
|
|
391
416
|
return (0, utils_1.assertUnreachable)(chainNamespace);
|
|
392
417
|
}
|
|
@@ -25,9 +25,15 @@ const getQuote = async (input, deps) => {
|
|
|
25
25
|
});
|
|
26
26
|
const buyPoolId = (0, index_1.getPoolAssetId)({ assetId: buyAssetId, swapperName });
|
|
27
27
|
const sellPoolId = (0, index_1.getPoolAssetId)({ assetId: sellAsset.assetId, swapperName });
|
|
28
|
-
const sellAmountCryptoPrecision =
|
|
28
|
+
const sellAmountCryptoPrecision = utils_1.BigAmount.fromBaseUnit({
|
|
29
|
+
value: sellAmountCryptoBaseUnit,
|
|
30
|
+
precision: sellAsset.precision,
|
|
31
|
+
}).toPrecision();
|
|
29
32
|
// All pool amounts are native precision regardless of token precision
|
|
30
|
-
const sellAmountCryptoThorBaseUnit = (0, utils_1.bn)(
|
|
33
|
+
const sellAmountCryptoThorBaseUnit = (0, utils_1.bn)(utils_1.BigAmount.fromPrecision({
|
|
34
|
+
value: sellAmountCryptoPrecision,
|
|
35
|
+
precision: (0, index_1.getNativePrecision)(sellAsset.assetId, swapperName),
|
|
36
|
+
}).toBaseUnit());
|
|
31
37
|
// The swap endpoint expects BCH receiveAddress's to be stripped of the "bitcoincash:" prefix
|
|
32
38
|
const parsedReceiveAddress = receiveAddress && buyAssetId === caip_1.bchAssetId
|
|
33
39
|
? receiveAddress.replace('bitcoincash:', '')
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUnsignedTronTransaction = void 0;
|
|
4
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
5
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
6
|
const utils_2 = require("../utils");
|
|
6
7
|
const getUnsignedTronTransaction = ({ stepIndex, tradeQuote, from, assertGetTronChainAdapter, }) => {
|
|
7
8
|
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
|
|
8
9
|
throw new Error('Unable to execute a trade rate quote');
|
|
9
10
|
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
10
|
-
const { accountNumber, sellAsset, relayTransactionMetadata, nearIntentsSpecific } = step;
|
|
11
|
+
const { accountNumber, sellAsset, relayTransactionMetadata, nearIntentsSpecific, butterSwapTransactionMetadata, } = step;
|
|
11
12
|
const adapter = assertGetTronChainAdapter(sellAsset.chainId);
|
|
13
|
+
if (butterSwapTransactionMetadata) {
|
|
14
|
+
const { to, data, method, args, value: butterValue } = butterSwapTransactionMetadata;
|
|
15
|
+
if (!to)
|
|
16
|
+
throw new Error('Missing Butter swap contract address');
|
|
17
|
+
if (!data)
|
|
18
|
+
throw new Error('Missing Butter swap transaction data');
|
|
19
|
+
// Use Butter's value field which includes swap fees for same-chain swaps
|
|
20
|
+
// For native TRX sells, also include the sell amount
|
|
21
|
+
const isNativeTron = sellAsset.assetId === caip_1.tronAssetId;
|
|
22
|
+
const value = isNativeTron ? step.sellAmountIncludingProtocolFeesCryptoBaseUnit : butterValue;
|
|
23
|
+
return adapter.buildCustomApiTx({
|
|
24
|
+
from,
|
|
25
|
+
to,
|
|
26
|
+
accountNumber,
|
|
27
|
+
data,
|
|
28
|
+
value,
|
|
29
|
+
method,
|
|
30
|
+
args,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
12
33
|
const to = relayTransactionMetadata?.to ?? nearIntentsSpecific?.depositAddress;
|
|
13
34
|
if (!to)
|
|
14
35
|
throw new Error('Missing transaction destination address');
|
|
15
36
|
const value = step.sellAmountIncludingProtocolFeesCryptoBaseUnit;
|
|
16
|
-
// Extract contract address for TRC20 tokens
|
|
17
37
|
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
18
38
|
return adapter.buildSendApiTransaction({
|
|
19
39
|
to,
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { QuoteResponse } from '@jup-ag/api';
|
|
2
2
|
import type { AccountId, AssetId, ChainId, Nominal } from '@shapeshiftoss/caip';
|
|
3
|
-
import type { ChainAdapter, CosmosSdkChainAdapter, EvmChainAdapter, near, SignTx, solana, starknet, sui, tron, UtxoChainAdapter } from '@shapeshiftoss/chain-adapters';
|
|
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, TronChainId, UtxoAccountType, UtxoChainId } from '@shapeshiftoss/types';
|
|
5
|
+
import type { AccountMetadata, Asset, AssetsByIdPartial, CosmosSdkChainId, EvmChainId, KnownChainIds, NearChainId, OrderQuoteResponse, PartialRecord, 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';
|
|
@@ -11,6 +11,7 @@ import type { Mixpanel } from 'mixpanel-browser';
|
|
|
11
11
|
import type Polyglot from 'node-polyglot';
|
|
12
12
|
import type { InterpolationOptions } from 'node-polyglot';
|
|
13
13
|
import type { Address, Hex } from 'viem';
|
|
14
|
+
import type { AcrossTransactionMetadata } from './swappers/AcrossSwapper/utils/types';
|
|
14
15
|
import type { CowMessageToSign } from './swappers/CowSwapper/types';
|
|
15
16
|
import type { RelayTransactionMetadata } from './swappers/RelaySwapper/utils/types';
|
|
16
17
|
import type { makeSwapperAxiosServiceMonadic } from './utils';
|
|
@@ -47,6 +48,8 @@ export type SwapperConfig = {
|
|
|
47
48
|
VITE_TENDERLY_ACCOUNT_SLUG: string;
|
|
48
49
|
VITE_TENDERLY_PROJECT_SLUG: string;
|
|
49
50
|
VITE_SUI_NODE_URL: string;
|
|
51
|
+
VITE_ACROSS_API_URL: string;
|
|
52
|
+
VITE_ACROSS_INTEGRATOR_ID: string;
|
|
50
53
|
};
|
|
51
54
|
export declare enum SwapperName {
|
|
52
55
|
Thorchain = "THORChain",
|
|
@@ -64,7 +67,9 @@ export declare enum SwapperName {
|
|
|
64
67
|
NearIntents = "NEAR Intents",
|
|
65
68
|
Cetus = "Cetus",
|
|
66
69
|
Sunio = "Sun.io",
|
|
67
|
-
Avnu = "AVNU"
|
|
70
|
+
Avnu = "AVNU",
|
|
71
|
+
Stonfi = "STON.fi",
|
|
72
|
+
Across = "Across"
|
|
68
73
|
}
|
|
69
74
|
export type SwapSource = SwapperName | `${SwapperName} • ${string}`;
|
|
70
75
|
export type SwapErrorRight = {
|
|
@@ -183,6 +188,15 @@ export type GetNearTradeQuoteInput = CommonTradeInput & {
|
|
|
183
188
|
export type GetNearTradeRateInput = CommonTradeRateInput & {
|
|
184
189
|
chainId: NearChainId;
|
|
185
190
|
};
|
|
191
|
+
export type GetTonTradeQuoteInputBase = CommonTradeInput & {
|
|
192
|
+
chainId: TonChainId;
|
|
193
|
+
};
|
|
194
|
+
export type GetTonTradeQuoteInput = CommonTradeInput & {
|
|
195
|
+
chainId: TonChainId;
|
|
196
|
+
};
|
|
197
|
+
export type GetTonTradeRateInput = CommonTradeRateInput & {
|
|
198
|
+
chainId: TonChainId;
|
|
199
|
+
};
|
|
186
200
|
type GetUtxoTradeQuoteWithWallet = CommonTradeQuoteInput & {
|
|
187
201
|
chainId: UtxoChainId;
|
|
188
202
|
accountType: UtxoAccountType;
|
|
@@ -196,9 +210,9 @@ export type GetUtxoTradeRateInput = CommonTradeRateInput & {
|
|
|
196
210
|
xpub: string | undefined;
|
|
197
211
|
};
|
|
198
212
|
export type GetUtxoTradeQuoteInput = GetUtxoTradeQuoteWithWallet;
|
|
199
|
-
export type GetTradeQuoteInput = GetUtxoTradeQuoteInput | GetEvmTradeQuoteInput | GetCosmosSdkTradeQuoteInput | GetTronTradeQuoteInput | GetNearTradeQuoteInput;
|
|
200
|
-
export type GetTradeRateInput = GetEvmTradeRateInput | GetCosmosSdkTradeRateInput | GetUtxoTradeRateInput | GetTronTradeRateInput | GetNearTradeRateInput;
|
|
201
|
-
export type GetTradeQuoteInputWithWallet = GetUtxoTradeQuoteWithWallet | GetEvmTradeQuoteInputBase | GetCosmosSdkTradeQuoteInputBase | GetTronTradeQuoteInputBase | GetNearTradeQuoteInputBase;
|
|
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;
|
|
202
216
|
export type EvmSwapperDeps = {
|
|
203
217
|
assertGetEvmChainAdapter: (chainId: ChainId) => EvmChainAdapter;
|
|
204
218
|
fetchIsSmartContractAddressQuery: (userAddress: string, chainId: ChainId) => Promise<boolean>;
|
|
@@ -224,12 +238,15 @@ export type NearSwapperDeps = {
|
|
|
224
238
|
export type StarknetSwapperDeps = {
|
|
225
239
|
assertGetStarknetChainAdapter: (chainId: ChainId) => starknet.ChainAdapter;
|
|
226
240
|
};
|
|
241
|
+
export type TonSwapperDeps = {
|
|
242
|
+
assertGetTonChainAdapter: (chainId: ChainId) => ton.ChainAdapter;
|
|
243
|
+
};
|
|
227
244
|
export type SwapperDeps = {
|
|
228
245
|
assetsById: AssetsByIdPartial;
|
|
229
246
|
config: SwapperConfig;
|
|
230
247
|
mixPanel: Mixpanel | undefined;
|
|
231
248
|
assertGetChainAdapter: (chainId: ChainId) => ChainAdapter<KnownChainIds>;
|
|
232
|
-
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & TronSwapperDeps & SuiSwapperDeps & NearSwapperDeps & StarknetSwapperDeps;
|
|
249
|
+
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & TronSwapperDeps & SuiSwapperDeps & NearSwapperDeps & StarknetSwapperDeps & TonSwapperDeps;
|
|
233
250
|
export type TradeQuoteStep = {
|
|
234
251
|
buyAmountBeforeFeesCryptoBaseUnit: string;
|
|
235
252
|
buyAmountAfterFeesCryptoBaseUnit: string;
|
|
@@ -297,6 +314,13 @@ export type TradeQuoteStep = {
|
|
|
297
314
|
data: string;
|
|
298
315
|
value: Hex;
|
|
299
316
|
gasLimit: string;
|
|
317
|
+
method?: string;
|
|
318
|
+
args?: {
|
|
319
|
+
type: string;
|
|
320
|
+
value: unknown;
|
|
321
|
+
}[];
|
|
322
|
+
memo?: string;
|
|
323
|
+
serializedSolanaTransaction?: string;
|
|
300
324
|
};
|
|
301
325
|
sunioTransactionMetadata?: {
|
|
302
326
|
route: {
|
|
@@ -317,6 +341,41 @@ export type TradeQuoteStep = {
|
|
|
317
341
|
quoteId: string;
|
|
318
342
|
routes: any[];
|
|
319
343
|
};
|
|
344
|
+
stonfiSpecific?: {
|
|
345
|
+
quoteId: string;
|
|
346
|
+
resolverId: string;
|
|
347
|
+
resolverName: string;
|
|
348
|
+
tradeStartDeadline: number;
|
|
349
|
+
gasBudget: string;
|
|
350
|
+
bidAssetAddress: {
|
|
351
|
+
blockchain: number;
|
|
352
|
+
address: string;
|
|
353
|
+
};
|
|
354
|
+
askAssetAddress: {
|
|
355
|
+
blockchain: number;
|
|
356
|
+
address: string;
|
|
357
|
+
};
|
|
358
|
+
bidUnits: string;
|
|
359
|
+
askUnits: string;
|
|
360
|
+
referrerAddress?: {
|
|
361
|
+
blockchain: number;
|
|
362
|
+
address: string;
|
|
363
|
+
};
|
|
364
|
+
referrerFeeAsset?: {
|
|
365
|
+
blockchain: number;
|
|
366
|
+
address: string;
|
|
367
|
+
};
|
|
368
|
+
referrerFeeUnits: string;
|
|
369
|
+
protocolFeeAsset?: {
|
|
370
|
+
blockchain: number;
|
|
371
|
+
address: string;
|
|
372
|
+
};
|
|
373
|
+
protocolFeeUnits: string;
|
|
374
|
+
quoteTimestamp: number;
|
|
375
|
+
estimatedGasConsumption: string;
|
|
376
|
+
params?: unknown;
|
|
377
|
+
};
|
|
378
|
+
acrossTransactionMetadata?: AcrossTransactionMetadata;
|
|
320
379
|
};
|
|
321
380
|
export type TradeRateStep = Omit<TradeQuoteStep, 'accountNumber'> & {
|
|
322
381
|
accountNumber: undefined;
|
|
@@ -370,6 +429,7 @@ export type SwapperSpecificMetadata = {
|
|
|
370
429
|
deadline: string;
|
|
371
430
|
};
|
|
372
431
|
relayTransactionMetadata: RelayTransactionMetadata | undefined;
|
|
432
|
+
acrossTransactionMetadata: AcrossTransactionMetadata | undefined;
|
|
373
433
|
relayerExplorerTxLink: string | undefined;
|
|
374
434
|
relayerTxHash: string | undefined;
|
|
375
435
|
stepIndex: SupportedTradeQuoteStepIndex;
|
|
@@ -475,6 +535,9 @@ export type NearTransactionExecutionProps = {
|
|
|
475
535
|
export type StarknetTransactionExecutionProps = {
|
|
476
536
|
signAndBroadcastTransaction: (txToSign: StarknetSignTx) => Promise<string>;
|
|
477
537
|
};
|
|
538
|
+
export type TonTransactionExecutionProps = {
|
|
539
|
+
signAndBroadcastTransaction: (txToSign: ton.TonSignTx) => Promise<string>;
|
|
540
|
+
};
|
|
478
541
|
type EvmAccountMetadata = {
|
|
479
542
|
from: string;
|
|
480
543
|
};
|
|
@@ -517,6 +580,10 @@ export type GetUnsignedTronTransactionArgs = CommonGetUnsignedTransactionArgs &
|
|
|
517
580
|
export type GetUnsignedSuiTransactionArgs = CommonGetUnsignedTransactionArgs & SuiAccountMetadata & SuiSwapperDeps;
|
|
518
581
|
export type GetUnsignedNearTransactionArgs = CommonGetUnsignedTransactionArgs & NearAccountMetadata & NearSwapperDeps;
|
|
519
582
|
export type GetUnsignedStarknetTransactionArgs = CommonGetUnsignedTransactionArgs & StarknetAccountMetadata & StarknetSwapperDeps;
|
|
583
|
+
type TonAccountMetadata = {
|
|
584
|
+
from: string;
|
|
585
|
+
};
|
|
586
|
+
export type GetUnsignedTonTransactionArgs = CommonGetUnsignedTransactionArgs & TonAccountMetadata & TonSwapperDeps;
|
|
520
587
|
export type GetUnsignedEvmMessageArgs = CommonGetUnsignedTransactionArgs & EvmAccountMetadata & Omit<EvmSwapperDeps, 'fetchIsSmartContractAddressQuery'>;
|
|
521
588
|
export type GetUnsignedUtxoTransactionArgs = CommonGetUnsignedTransactionArgs & UtxoAccountMetadata & UtxoSwapperDeps;
|
|
522
589
|
export type GetUnsignedCosmosSdkTransactionArgs = CommonGetUnsignedTransactionArgs & CosmosSdkAccountMetadata & CosmosSdkSwapperDeps;
|
|
@@ -535,7 +602,7 @@ export type CheckTradeStatusInput = {
|
|
|
535
602
|
stepIndex: SupportedTradeQuoteStepIndex;
|
|
536
603
|
config: SwapperConfig;
|
|
537
604
|
swap: Swap | undefined;
|
|
538
|
-
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & TronSwapperDeps & SuiSwapperDeps & NearSwapperDeps & StarknetSwapperDeps;
|
|
605
|
+
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & TronSwapperDeps & SuiSwapperDeps & NearSwapperDeps & StarknetSwapperDeps & TonSwapperDeps;
|
|
539
606
|
export type TradeStatus = {
|
|
540
607
|
status: TxStatus;
|
|
541
608
|
buyTxHash: string | undefined;
|
|
@@ -558,6 +625,7 @@ export type Swapper = {
|
|
|
558
625
|
executeSuiTransaction?: (txToSign: SuiSignTx, callbacks: SuiTransactionExecutionProps) => Promise<string>;
|
|
559
626
|
executeNearTransaction?: (txToSign: near.NearSignTx, callbacks: NearTransactionExecutionProps) => Promise<string>;
|
|
560
627
|
executeStarknetTransaction?: (txToSign: StarknetSignTx, callbacks: StarknetTransactionExecutionProps) => Promise<string>;
|
|
628
|
+
executeTonTransaction?: (txToSign: ton.TonSignTx, callbacks: TonTransactionExecutionProps) => Promise<string>;
|
|
561
629
|
};
|
|
562
630
|
export type SwapperApi = {
|
|
563
631
|
checkTradeStatus: (input: CheckTradeStatusInput) => Promise<TradeStatus>;
|
|
@@ -573,6 +641,7 @@ export type SwapperApi = {
|
|
|
573
641
|
getUnsignedSuiTransaction?: (input: GetUnsignedSuiTransactionArgs) => Promise<SuiSignTx>;
|
|
574
642
|
getUnsignedNearTransaction?: (input: GetUnsignedNearTransactionArgs) => Promise<near.NearSignTx>;
|
|
575
643
|
getUnsignedStarknetTransaction?: (input: GetUnsignedStarknetTransactionArgs) => Promise<StarknetSignTx>;
|
|
644
|
+
getUnsignedTonTransaction?: (input: GetUnsignedTonTransactionArgs) => Promise<ton.TonSignTx>;
|
|
576
645
|
getEvmTransactionFees?: (input: GetUnsignedEvmTransactionArgs) => Promise<string>;
|
|
577
646
|
getSolanaTransactionFees?: (input: GetUnsignedSolanaTransactionArgs) => Promise<string>;
|
|
578
647
|
getSuiTransactionFees?: (input: GetUnsignedSuiTransactionArgs) => Promise<string>;
|
|
@@ -581,6 +650,7 @@ export type SwapperApi = {
|
|
|
581
650
|
getTronTransactionFees?: (input: GetUnsignedTronTransactionArgs) => Promise<string>;
|
|
582
651
|
getNearTransactionFees?: (input: GetUnsignedNearTransactionArgs) => Promise<string>;
|
|
583
652
|
getStarknetTransactionFees?: (input: GetUnsignedStarknetTransactionArgs) => Promise<string>;
|
|
653
|
+
getTonTransactionFees?: (input: GetUnsignedTonTransactionArgs) => Promise<string>;
|
|
584
654
|
};
|
|
585
655
|
export type QuoteResult = Result<TradeQuote[], SwapErrorRight> & {
|
|
586
656
|
swapperName: SwapperName;
|
|
@@ -607,6 +677,7 @@ export type TronTransactionExecutionInput = CommonTradeExecutionInput & TronTran
|
|
|
607
677
|
export type SuiTransactionExecutionInput = CommonTradeExecutionInput & SuiTransactionExecutionProps & SuiAccountMetadata;
|
|
608
678
|
export type NearTransactionExecutionInput = CommonTradeExecutionInput & NearTransactionExecutionProps & NearAccountMetadata;
|
|
609
679
|
export type StarknetTransactionExecutionInput = CommonTradeExecutionInput & StarknetTransactionExecutionProps & StarknetAccountMetadata;
|
|
680
|
+
export type TonTransactionExecutionInput = CommonTradeExecutionInput & TonTransactionExecutionProps & TonAccountMetadata;
|
|
610
681
|
export declare enum TradeExecutionEvent {
|
|
611
682
|
SellTxHash = "sellTxHash",
|
|
612
683
|
RelayerTxHash = "relayerTxHash",
|
package/dist/cjs/types.js
CHANGED
|
@@ -19,6 +19,8 @@ var SwapperName;
|
|
|
19
19
|
SwapperName["Cetus"] = "Cetus";
|
|
20
20
|
SwapperName["Sunio"] = "Sun.io";
|
|
21
21
|
SwapperName["Avnu"] = "AVNU";
|
|
22
|
+
SwapperName["Stonfi"] = "STON.fi";
|
|
23
|
+
SwapperName["Across"] = "Across";
|
|
22
24
|
})(SwapperName || (exports.SwapperName = SwapperName = {}));
|
|
23
25
|
var TradeQuoteError;
|
|
24
26
|
(function (TradeQuoteError) {
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
import type { EvmChainAdapter, near, SignTx, solana, starknet, sui } from '@shapeshiftoss/chain-adapters';
|
|
2
|
+
import type { EvmChainAdapter, near, SignTx, solana, starknet, sui, ton } from '@shapeshiftoss/chain-adapters';
|
|
3
|
+
import type { TronSignTx } from '@shapeshiftoss/chain-adapters/src/tron/types';
|
|
3
4
|
import type { SolanaSignTx, StarknetSignTx, SuiSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
4
5
|
import type { Asset, EvmChainId } from '@shapeshiftoss/types';
|
|
5
6
|
import { TxStatus } from '@shapeshiftoss/unchained-client';
|
|
6
7
|
import type { Result } from '@sniptt/monads';
|
|
7
8
|
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
8
|
-
import type {
|
|
9
|
-
import type { EvmTransactionExecutionProps, ExecutableTradeStep, NearTransactionExecutionProps, SolanaTransactionExecutionProps, StarknetTransactionExecutionProps, SuiTransactionExecutionProps, SupportedTradeQuoteStepIndex, SwapErrorRight, TradeQuote, TradeQuoteStep, TradeRate, TradeStatus, TronTransactionExecutionProps } from './types';
|
|
9
|
+
import type { EvmTransactionExecutionProps, ExecutableTradeStep, NearTransactionExecutionProps, SolanaTransactionExecutionProps, StarknetTransactionExecutionProps, SuiTransactionExecutionProps, SupportedTradeQuoteStepIndex, SwapErrorRight, TonTransactionExecutionProps, TradeQuote, TradeQuoteStep, TradeRate, TradeStatus, TronTransactionExecutionProps } from './types';
|
|
10
10
|
import { TradeQuoteError } from './types';
|
|
11
11
|
export declare const makeSwapErrorRight: ({ details, cause, code, message, }: {
|
|
12
12
|
message: string;
|
|
@@ -32,6 +32,7 @@ export declare const executeTronTransaction: (txToSign: TronSignTx, callbacks: T
|
|
|
32
32
|
export declare const executeSuiTransaction: (txToSign: SuiSignTx, callbacks: SuiTransactionExecutionProps) => Promise<string>;
|
|
33
33
|
export declare const executeNearTransaction: (txToSign: near.NearSignTx, callbacks: NearTransactionExecutionProps) => Promise<string>;
|
|
34
34
|
export declare const executeStarknetTransaction: (txToSign: StarknetSignTx, callbacks: StarknetTransactionExecutionProps) => Promise<string>;
|
|
35
|
+
export declare const executeTonTransaction: (txToSign: ton.TonSignTx, callbacks: TonTransactionExecutionProps) => Promise<string>;
|
|
35
36
|
export declare const createDefaultStatusResponse: (buyTxHash?: string) => {
|
|
36
37
|
status: TxStatus;
|
|
37
38
|
buyTxHash: string | undefined;
|