@shapeshiftoss/swapper 17.6.6-alpha.1 → 17.6.7
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 +27 -18
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +2 -0
- package/dist/cjs/swappers/ButterSwap/swapperApi/getTradeRate.test.js +4 -0
- package/dist/cjs/swappers/CetusSwapper/CetusSwapper.d.ts +2 -0
- package/dist/cjs/swappers/CetusSwapper/CetusSwapper.js +7 -0
- package/dist/cjs/swappers/CetusSwapper/endpoints.d.ts +2 -0
- package/dist/cjs/swappers/CetusSwapper/endpoints.js +87 -0
- package/dist/cjs/swappers/CetusSwapper/index.d.ts +1 -0
- package/dist/cjs/swappers/CetusSwapper/index.js +17 -0
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.d.ts +3 -0
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeQuote.js +122 -0
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.d.ts +3 -0
- package/dist/cjs/swappers/CetusSwapper/swapperApi/getTradeRate.js +110 -0
- package/dist/cjs/swappers/CetusSwapper/utils/constants.d.ts +3 -0
- package/dist/cjs/swappers/CetusSwapper/utils/constants.js +9 -0
- package/dist/cjs/swappers/CetusSwapper/utils/helpers.d.ts +13 -0
- package/dist/cjs/swappers/CetusSwapper/utils/helpers.js +118 -0
- package/dist/cjs/swappers/NearIntentsSwapper/NearIntentsSwapper.js +2 -0
- package/dist/cjs/swappers/NearIntentsSwapper/endpoints.js +43 -0
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +50 -10
- package/dist/cjs/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +65 -9
- package/dist/cjs/swappers/NearIntentsSwapper/types.d.ts +2 -2
- package/dist/cjs/swappers/NearIntentsSwapper/types.js +4 -0
- package/dist/cjs/swappers/NearIntentsSwapper/utils/helpers/helpers.js +12 -7
- package/dist/cjs/swappers/RelaySwapper/RelaySwapper.js +1 -0
- package/dist/cjs/swappers/RelaySwapper/constant.d.ts +2 -2
- package/dist/cjs/swappers/RelaySwapper/constant.js +27 -36
- package/dist/cjs/swappers/RelaySwapper/endpoints.js +4 -0
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayAssetAddress.js +2 -0
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.d.ts +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.js +2 -0
- package/dist/cjs/swappers/RelaySwapper/utils/getRelayPsbtRelayer.js +1 -1
- package/dist/cjs/swappers/RelaySwapper/utils/getTrade.js +7 -2
- package/dist/cjs/swappers/RelaySwapper/utils/relayTokenToAssetId.js +15 -0
- package/dist/cjs/thorchain-utils/getL1RateOrQuote.js +12 -0
- package/dist/cjs/tron-utils/getTronTransactionFees.d.ts +2 -0
- package/dist/cjs/tron-utils/getTronTransactionFees.js +14 -0
- package/dist/cjs/tron-utils/getUnsignedTronTransaction.d.ts +2 -0
- package/dist/cjs/tron-utils/getUnsignedTronTransaction.js +28 -0
- package/dist/cjs/types.d.ts +56 -11
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/utils.d.ts +11 -3
- package/dist/cjs/utils.js +34 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.js +9 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeQuote.test.js +2 -0
- package/dist/esm/swappers/ButterSwap/swapperApi/getTradeRate.test.js +4 -0
- package/dist/esm/swappers/CetusSwapper/CetusSwapper.d.ts +2 -0
- package/dist/esm/swappers/CetusSwapper/CetusSwapper.js +4 -0
- package/dist/esm/swappers/CetusSwapper/endpoints.d.ts +2 -0
- package/dist/esm/swappers/CetusSwapper/endpoints.js +84 -0
- package/dist/esm/swappers/CetusSwapper/index.d.ts +1 -0
- package/dist/esm/swappers/CetusSwapper/index.js +1 -0
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.d.ts +3 -0
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeQuote.js +118 -0
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.d.ts +3 -0
- package/dist/esm/swappers/CetusSwapper/swapperApi/getTradeRate.js +106 -0
- package/dist/esm/swappers/CetusSwapper/utils/constants.d.ts +3 -0
- package/dist/esm/swappers/CetusSwapper/utils/constants.js +5 -0
- package/dist/esm/swappers/CetusSwapper/utils/helpers.d.ts +13 -0
- package/dist/esm/swappers/CetusSwapper/utils/helpers.js +86 -0
- package/dist/esm/swappers/NearIntentsSwapper/NearIntentsSwapper.js +3 -1
- package/dist/esm/swappers/NearIntentsSwapper/endpoints.js +43 -0
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.js +51 -11
- package/dist/esm/swappers/NearIntentsSwapper/swapperApi/getTradeRate.js +66 -10
- package/dist/esm/swappers/NearIntentsSwapper/types.d.ts +2 -2
- package/dist/esm/swappers/NearIntentsSwapper/types.js +4 -0
- package/dist/esm/swappers/NearIntentsSwapper/utils/helpers/helpers.js +13 -8
- package/dist/esm/swappers/RelaySwapper/RelaySwapper.js +2 -1
- package/dist/esm/swappers/RelaySwapper/constant.d.ts +2 -2
- package/dist/esm/swappers/RelaySwapper/constant.js +6 -15
- package/dist/esm/swappers/RelaySwapper/endpoints.js +4 -0
- package/dist/esm/swappers/RelaySwapper/utils/getRelayAssetAddress.js +4 -2
- package/dist/esm/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.d.ts +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/getRelayDefaultUserAddress.js +4 -2
- package/dist/esm/swappers/RelaySwapper/utils/getRelayPsbtRelayer.js +1 -1
- package/dist/esm/swappers/RelaySwapper/utils/getTrade.js +8 -3
- package/dist/esm/swappers/RelaySwapper/utils/relayTokenToAssetId.js +17 -2
- package/dist/esm/thorchain-utils/getL1RateOrQuote.js +12 -0
- package/dist/esm/tron-utils/getTronTransactionFees.d.ts +2 -0
- package/dist/esm/tron-utils/getTronTransactionFees.js +10 -0
- package/dist/esm/tron-utils/getUnsignedTronTransaction.d.ts +2 -0
- package/dist/esm/tron-utils/getUnsignedTronTransaction.js +24 -0
- package/dist/esm/types.d.ts +56 -11
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils.d.ts +11 -3
- package/dist/esm/utils.js +31 -1
- package/package.json +17 -10
|
@@ -32,7 +32,8 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
32
32
|
const buyRelayChainId = relayChainMap[buyAsset.chainId];
|
|
33
33
|
if (!(0, chain_adapters_1.isEvmChainId)(sellAsset.chainId) &&
|
|
34
34
|
sellAsset.chainId !== caip_1.btcChainId &&
|
|
35
|
-
sellAsset.chainId !== caip_1.solanaChainId
|
|
35
|
+
sellAsset.chainId !== caip_1.solanaChainId &&
|
|
36
|
+
sellAsset.chainId !== caip_1.tronChainId) {
|
|
36
37
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
37
38
|
message: `asset '${sellAsset.name}' on chainId '${sellAsset.chainId}' not supported`,
|
|
38
39
|
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
@@ -40,7 +41,8 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
40
41
|
}
|
|
41
42
|
if (!(0, chain_adapters_1.isEvmChainId)(buyAsset.chainId) &&
|
|
42
43
|
buyAsset.chainId !== caip_1.btcChainId &&
|
|
43
|
-
buyAsset.chainId !== caip_1.solanaChainId
|
|
44
|
+
buyAsset.chainId !== caip_1.solanaChainId &&
|
|
45
|
+
buyAsset.chainId !== caip_1.tronChainId) {
|
|
44
46
|
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
45
47
|
message: `asset '${buyAsset.name}' on chainId '${buyAsset.chainId}' not supported`,
|
|
46
48
|
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
@@ -217,6 +219,9 @@ async function getTrade({ input, deps, relayChainMap, }) {
|
|
|
217
219
|
if (sellAsset.chainId === caip_1.solanaChainId) {
|
|
218
220
|
return sellAsset.assetId === appFeesAsset.assetId;
|
|
219
221
|
}
|
|
222
|
+
if (sellAsset.chainId === caip_1.tronChainId) {
|
|
223
|
+
return sellAsset.assetId === appFeesAsset.assetId;
|
|
224
|
+
}
|
|
220
225
|
return false;
|
|
221
226
|
})();
|
|
222
227
|
const appFeesBaseUnit = (() => {
|
|
@@ -17,6 +17,9 @@ const relayTokenToAssetId = (relayToken) => {
|
|
|
17
17
|
if (chainId === caip_1.solanaChainId) {
|
|
18
18
|
return relayToken.address === constant_1.RELAY_SOLANA_TOKEN_ADDRESS;
|
|
19
19
|
}
|
|
20
|
+
if (chainId === caip_1.tronChainId) {
|
|
21
|
+
return relayToken.address === constant_1.RELAY_TRON_TOKEN_ADDRESS;
|
|
22
|
+
}
|
|
20
23
|
return false;
|
|
21
24
|
})();
|
|
22
25
|
const { assetReference, assetNamespace } = (() => {
|
|
@@ -27,6 +30,8 @@ const relayTokenToAssetId = (relayToken) => {
|
|
|
27
30
|
return caip_1.ASSET_NAMESPACE.erc20;
|
|
28
31
|
case caip_1.CHAIN_REFERENCE.SolanaMainnet === chainReference:
|
|
29
32
|
return caip_1.ASSET_NAMESPACE.splToken;
|
|
33
|
+
case caip_1.CHAIN_REFERENCE.TronMainnet === chainReference:
|
|
34
|
+
return caip_1.ASSET_NAMESPACE.trc20;
|
|
30
35
|
default:
|
|
31
36
|
throw Error(`chainReference '${chainReference}' not supported`);
|
|
32
37
|
}
|
|
@@ -82,6 +87,16 @@ const relayTokenToAssetId = (relayToken) => {
|
|
|
82
87
|
assetReference: caip_1.ASSET_REFERENCE.Solana,
|
|
83
88
|
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
84
89
|
};
|
|
90
|
+
case caip_1.CHAIN_REFERENCE.TronMainnet:
|
|
91
|
+
return {
|
|
92
|
+
assetReference: caip_1.ASSET_REFERENCE.Tron,
|
|
93
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
94
|
+
};
|
|
95
|
+
case caip_1.CHAIN_REFERENCE.MonadMainnet:
|
|
96
|
+
return {
|
|
97
|
+
assetReference: caip_1.ASSET_REFERENCE.Monad,
|
|
98
|
+
assetNamespace: caip_1.ASSET_NAMESPACE.slip44,
|
|
99
|
+
};
|
|
85
100
|
default:
|
|
86
101
|
throw Error(`chainId '${relayToken.chainId}' not supported`);
|
|
87
102
|
}
|
|
@@ -298,6 +298,18 @@ const getL1RateOrQuote = async (input, deps, streamingInterval, tradeType, swapp
|
|
|
298
298
|
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
299
299
|
}));
|
|
300
300
|
}
|
|
301
|
+
case caip_1.CHAIN_NAMESPACE.Tron: {
|
|
302
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
303
|
+
message: 'Tron is not supported',
|
|
304
|
+
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
case caip_1.CHAIN_NAMESPACE.Sui: {
|
|
308
|
+
return (0, monads_1.Err)((0, utils_2.makeSwapErrorRight)({
|
|
309
|
+
message: 'SUI is not supported',
|
|
310
|
+
code: types_1.TradeQuoteError.UnsupportedTradePair,
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
301
313
|
default:
|
|
302
314
|
return (0, utils_1.assertUnreachable)(chainNamespace);
|
|
303
315
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTronTransactionFees = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const getTronTransactionFees = ({ tradeQuote, stepIndex, }) => {
|
|
6
|
+
if (!(0, utils_1.isExecutableTradeQuote)(tradeQuote))
|
|
7
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
8
|
+
const step = (0, utils_1.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
9
|
+
if (!step.feeData.networkFeeCryptoBaseUnit) {
|
|
10
|
+
throw new Error('Missing network fee in quote');
|
|
11
|
+
}
|
|
12
|
+
return Promise.resolve(step.feeData.networkFeeCryptoBaseUnit);
|
|
13
|
+
};
|
|
14
|
+
exports.getTronTransactionFees = getTronTransactionFees;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUnsignedTronTransaction = void 0;
|
|
4
|
+
const utils_1 = require("@shapeshiftoss/utils");
|
|
5
|
+
const utils_2 = require("../utils");
|
|
6
|
+
const getUnsignedTronTransaction = ({ stepIndex, tradeQuote, from, assertGetTronChainAdapter, }) => {
|
|
7
|
+
if (!(0, utils_2.isExecutableTradeQuote)(tradeQuote))
|
|
8
|
+
throw new Error('Unable to execute a trade rate quote');
|
|
9
|
+
const step = (0, utils_2.getExecutableTradeStep)(tradeQuote, stepIndex);
|
|
10
|
+
const { accountNumber, sellAsset, relayTransactionMetadata, nearIntentsSpecific } = step;
|
|
11
|
+
const adapter = assertGetTronChainAdapter(sellAsset.chainId);
|
|
12
|
+
const to = relayTransactionMetadata?.to ?? nearIntentsSpecific?.depositAddress;
|
|
13
|
+
if (!to)
|
|
14
|
+
throw new Error('Missing transaction destination address');
|
|
15
|
+
const value = step.sellAmountIncludingProtocolFeesCryptoBaseUnit;
|
|
16
|
+
// Extract contract address for TRC20 tokens
|
|
17
|
+
const contractAddress = (0, utils_1.contractAddressOrUndefined)(sellAsset.assetId);
|
|
18
|
+
return adapter.buildSendApiTransaction({
|
|
19
|
+
to,
|
|
20
|
+
from,
|
|
21
|
+
value,
|
|
22
|
+
accountNumber,
|
|
23
|
+
chainSpecific: {
|
|
24
|
+
contractAddress,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.getUnsignedTronTransaction = getUnsignedTronTransaction;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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, SignTx, solana, UtxoChainAdapter } from '@shapeshiftoss/chain-adapters';
|
|
4
|
-
import type { HDWallet, SolanaSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
5
|
-
import type { AccountMetadata, Asset, AssetsByIdPartial, CosmosSdkChainId, EvmChainId, KnownChainIds, OrderQuoteResponse, PartialRecord, UtxoAccountType, UtxoChainId } from '@shapeshiftoss/types';
|
|
3
|
+
import type { ChainAdapter, CosmosSdkChainAdapter, EvmChainAdapter, SignTx, solana, sui, tron, UtxoChainAdapter } from '@shapeshiftoss/chain-adapters';
|
|
4
|
+
import type { HDWallet, SolanaSignTx, SuiSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
5
|
+
import type { AccountMetadata, Asset, AssetsByIdPartial, CosmosSdkChainId, EvmChainId, KnownChainIds, OrderQuoteResponse, PartialRecord, 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';
|
|
9
9
|
import type { TypedData } from 'eip-712';
|
|
10
10
|
import type { Mixpanel } from 'mixpanel-browser';
|
|
11
|
-
import type { InterpolationOptions } from 'node-polyglot';
|
|
12
11
|
import type Polyglot from 'node-polyglot';
|
|
12
|
+
import type { InterpolationOptions } from 'node-polyglot';
|
|
13
13
|
import type { Address, Hex } from 'viem';
|
|
14
14
|
import type { CowMessageToSign } from './swappers/CowSwapper/types';
|
|
15
15
|
import type { RelayTransactionMetadata } from './swappers/RelaySwapper/utils/types';
|
|
@@ -59,7 +59,8 @@ export declare enum SwapperName {
|
|
|
59
59
|
Relay = "Relay",
|
|
60
60
|
ButterSwap = "ButterSwap",
|
|
61
61
|
Bebop = "Bebop",
|
|
62
|
-
NearIntents = "NEAR Intents"
|
|
62
|
+
NearIntents = "NEAR Intents",
|
|
63
|
+
Cetus = "Cetus"
|
|
63
64
|
}
|
|
64
65
|
export type SwapSource = SwapperName | `${SwapperName} • ${string}`;
|
|
65
66
|
export type SwapErrorRight = {
|
|
@@ -97,6 +98,10 @@ export type SolanaFeeData = {
|
|
|
97
98
|
computeUnits: string;
|
|
98
99
|
priorityFee: string;
|
|
99
100
|
};
|
|
101
|
+
export type SuiFeeData = {
|
|
102
|
+
gasBudget: string;
|
|
103
|
+
gasPrice: string;
|
|
104
|
+
};
|
|
100
105
|
export type AmountDisplayMeta = {
|
|
101
106
|
amountCryptoBaseUnit: string;
|
|
102
107
|
asset: Partial<Asset> & Pick<Asset, 'symbol' | 'chainId' | 'precision'>;
|
|
@@ -107,7 +112,7 @@ export type ProtocolFee = {
|
|
|
107
112
|
export type QuoteFeeData = {
|
|
108
113
|
networkFeeCryptoBaseUnit: string | undefined;
|
|
109
114
|
protocolFees: PartialRecord<AssetId, ProtocolFee> | undefined;
|
|
110
|
-
chainSpecific?: UtxoFeeData | CosmosSdkFeeData | SolanaFeeData;
|
|
115
|
+
chainSpecific?: UtxoFeeData | CosmosSdkFeeData | SolanaFeeData | SuiFeeData;
|
|
111
116
|
};
|
|
112
117
|
export type BuyAssetBySellIdInput = {
|
|
113
118
|
sellAsset: Asset;
|
|
@@ -153,9 +158,18 @@ export type GetCosmosSdkTradeQuoteInputBase = CommonTradeQuoteInput & {
|
|
|
153
158
|
export type GetCosmosSdkTradeQuoteInput = CommonTradeInput & {
|
|
154
159
|
chainId: CosmosSdkChainId;
|
|
155
160
|
};
|
|
161
|
+
export type GetTronTradeQuoteInputBase = CommonTradeInput & {
|
|
162
|
+
chainId: TronChainId;
|
|
163
|
+
};
|
|
164
|
+
export type GetTronTradeQuoteInput = CommonTradeInput & {
|
|
165
|
+
chainId: TronChainId;
|
|
166
|
+
};
|
|
156
167
|
export type GetCosmosSdkTradeRateInput = CommonTradeRateInput & {
|
|
157
168
|
chainId: CosmosSdkChainId;
|
|
158
169
|
};
|
|
170
|
+
export type GetTronTradeRateInput = CommonTradeRateInput & {
|
|
171
|
+
chainId: TronChainId;
|
|
172
|
+
};
|
|
159
173
|
type GetUtxoTradeQuoteWithWallet = CommonTradeQuoteInput & {
|
|
160
174
|
chainId: UtxoChainId;
|
|
161
175
|
accountType: UtxoAccountType;
|
|
@@ -169,9 +183,9 @@ export type GetUtxoTradeRateInput = CommonTradeRateInput & {
|
|
|
169
183
|
xpub: string | undefined;
|
|
170
184
|
};
|
|
171
185
|
export type GetUtxoTradeQuoteInput = GetUtxoTradeQuoteWithWallet;
|
|
172
|
-
export type GetTradeQuoteInput = GetUtxoTradeQuoteInput | GetEvmTradeQuoteInput | GetCosmosSdkTradeQuoteInput;
|
|
173
|
-
export type GetTradeRateInput = GetEvmTradeRateInput | GetCosmosSdkTradeRateInput | GetUtxoTradeRateInput;
|
|
174
|
-
export type GetTradeQuoteInputWithWallet = GetUtxoTradeQuoteWithWallet | GetEvmTradeQuoteInputBase | GetCosmosSdkTradeQuoteInputBase;
|
|
186
|
+
export type GetTradeQuoteInput = GetUtxoTradeQuoteInput | GetEvmTradeQuoteInput | GetCosmosSdkTradeQuoteInput | GetTronTradeQuoteInput;
|
|
187
|
+
export type GetTradeRateInput = GetEvmTradeRateInput | GetCosmosSdkTradeRateInput | GetUtxoTradeRateInput | GetTronTradeRateInput;
|
|
188
|
+
export type GetTradeQuoteInputWithWallet = GetUtxoTradeQuoteWithWallet | GetEvmTradeQuoteInputBase | GetCosmosSdkTradeQuoteInputBase | GetTronTradeQuoteInputBase;
|
|
175
189
|
export type EvmSwapperDeps = {
|
|
176
190
|
assertGetEvmChainAdapter: (chainId: ChainId) => EvmChainAdapter;
|
|
177
191
|
fetchIsSmartContractAddressQuery: (userAddress: string, chainId: ChainId) => Promise<boolean>;
|
|
@@ -185,12 +199,18 @@ export type CosmosSdkSwapperDeps = {
|
|
|
185
199
|
export type SolanaSwapperDeps = {
|
|
186
200
|
assertGetSolanaChainAdapter: (chainId: ChainId) => solana.ChainAdapter;
|
|
187
201
|
};
|
|
202
|
+
export type TronSwapperDeps = {
|
|
203
|
+
assertGetTronChainAdapter: (chainId: ChainId) => tron.ChainAdapter;
|
|
204
|
+
};
|
|
205
|
+
export type SuiSwapperDeps = {
|
|
206
|
+
assertGetSuiChainAdapter: (chainId: ChainId) => sui.ChainAdapter;
|
|
207
|
+
};
|
|
188
208
|
export type SwapperDeps = {
|
|
189
209
|
assetsById: AssetsByIdPartial;
|
|
190
210
|
config: SwapperConfig;
|
|
191
211
|
mixPanel: Mixpanel | undefined;
|
|
192
212
|
assertGetChainAdapter: (chainId: ChainId) => ChainAdapter<KnownChainIds>;
|
|
193
|
-
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps;
|
|
213
|
+
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & TronSwapperDeps & SuiSwapperDeps;
|
|
194
214
|
export type TradeQuoteStep = {
|
|
195
215
|
buyAmountBeforeFeesCryptoBaseUnit: string;
|
|
196
216
|
buyAmountAfterFeesCryptoBaseUnit: string;
|
|
@@ -296,6 +316,7 @@ export type SwapExecutionMetadata = {
|
|
|
296
316
|
buyTxHash?: string;
|
|
297
317
|
streamingSwap?: StreamingSwapMetadata;
|
|
298
318
|
message?: string | [string, InterpolationOptions];
|
|
319
|
+
inboundAddress?: string;
|
|
299
320
|
};
|
|
300
321
|
export type SwapperSpecificMetadata = {
|
|
301
322
|
chainflipSwapId: number | undefined;
|
|
@@ -335,6 +356,7 @@ export type Swap = {
|
|
|
335
356
|
swapperName: SwapperName;
|
|
336
357
|
sellAmountCryptoBaseUnit: string;
|
|
337
358
|
expectedBuyAmountCryptoBaseUnit: string;
|
|
359
|
+
actualBuyAmountCryptoBaseUnit?: string;
|
|
338
360
|
sellAmountCryptoPrecision: string;
|
|
339
361
|
expectedBuyAmountCryptoPrecision: string;
|
|
340
362
|
txLink?: string;
|
|
@@ -398,12 +420,24 @@ export type CosmosSdkTransactionExecutionProps = {
|
|
|
398
420
|
export type SolanaTransactionExecutionProps = {
|
|
399
421
|
signAndBroadcastTransaction: (txToSign: SolanaSignTx) => Promise<string>;
|
|
400
422
|
};
|
|
423
|
+
export type TronTransactionExecutionProps = {
|
|
424
|
+
signAndBroadcastTransaction: (txToSign: tron.TronSignTx) => Promise<string>;
|
|
425
|
+
};
|
|
426
|
+
export type SuiTransactionExecutionProps = {
|
|
427
|
+
signAndBroadcastTransaction: (txToSign: SuiSignTx) => Promise<string>;
|
|
428
|
+
};
|
|
401
429
|
type EvmAccountMetadata = {
|
|
402
430
|
from: string;
|
|
403
431
|
};
|
|
404
432
|
type SolanaAccountMetadata = {
|
|
405
433
|
from: string;
|
|
406
434
|
};
|
|
435
|
+
type TronAccountMetadata = {
|
|
436
|
+
from: string;
|
|
437
|
+
};
|
|
438
|
+
type SuiAccountMetadata = {
|
|
439
|
+
from: string;
|
|
440
|
+
};
|
|
407
441
|
type UtxoAccountMetadata = {
|
|
408
442
|
senderAddress: string;
|
|
409
443
|
xpub: string;
|
|
@@ -424,6 +458,8 @@ export type GetUnsignedEvmTransactionArgs = CommonGetUnsignedTransactionArgs & E
|
|
|
424
458
|
supportsEIP1559: boolean;
|
|
425
459
|
};
|
|
426
460
|
export type GetUnsignedSolanaTransactionArgs = CommonGetUnsignedTransactionArgs & SolanaAccountMetadata & SolanaSwapperDeps;
|
|
461
|
+
export type GetUnsignedTronTransactionArgs = CommonGetUnsignedTransactionArgs & TronAccountMetadata & TronSwapperDeps;
|
|
462
|
+
export type GetUnsignedSuiTransactionArgs = CommonGetUnsignedTransactionArgs & SuiAccountMetadata & SuiSwapperDeps;
|
|
427
463
|
export type GetUnsignedEvmMessageArgs = CommonGetUnsignedTransactionArgs & EvmAccountMetadata & Omit<EvmSwapperDeps, 'fetchIsSmartContractAddressQuery'>;
|
|
428
464
|
export type GetUnsignedUtxoTransactionArgs = CommonGetUnsignedTransactionArgs & UtxoAccountMetadata & UtxoSwapperDeps;
|
|
429
465
|
export type GetUnsignedCosmosSdkTransactionArgs = CommonGetUnsignedTransactionArgs & CosmosSdkAccountMetadata & CosmosSdkSwapperDeps;
|
|
@@ -442,13 +478,14 @@ export type CheckTradeStatusInput = {
|
|
|
442
478
|
stepIndex: SupportedTradeQuoteStepIndex;
|
|
443
479
|
config: SwapperConfig;
|
|
444
480
|
swap: Swap | undefined;
|
|
445
|
-
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps;
|
|
481
|
+
} & EvmSwapperDeps & UtxoSwapperDeps & CosmosSdkSwapperDeps & SolanaSwapperDeps & SuiSwapperDeps;
|
|
446
482
|
export type TradeStatus = {
|
|
447
483
|
status: TxStatus;
|
|
448
484
|
buyTxHash: string | undefined;
|
|
449
485
|
relayerTxHash?: string | undefined;
|
|
450
486
|
relayerExplorerTxLink?: string | undefined;
|
|
451
487
|
message: string | [string, InterpolationOptions] | undefined;
|
|
488
|
+
actualBuyAmountCryptoBaseUnit?: string;
|
|
452
489
|
};
|
|
453
490
|
export type TradeQuoteResult = Result<TradeQuote[], SwapErrorRight>;
|
|
454
491
|
export type TradeRateResult = Result<TradeRate[], SwapErrorRight>;
|
|
@@ -460,6 +497,8 @@ export type Swapper = {
|
|
|
460
497
|
executeUtxoTransaction?: (txToSign: SignTx<UtxoChainId>, callbacks: UtxoTransactionExecutionProps) => Promise<string>;
|
|
461
498
|
executeCosmosSdkTransaction?: (txToSign: SignTx<CosmosSdkChainId>, callbacks: CosmosSdkTransactionExecutionProps) => Promise<string>;
|
|
462
499
|
executeSolanaTransaction?: (txToSign: SolanaSignTx, callbacks: SolanaTransactionExecutionProps) => Promise<string>;
|
|
500
|
+
executeTronTransaction?: (txToSign: tron.TronSignTx, callbacks: TronTransactionExecutionProps) => Promise<string>;
|
|
501
|
+
executeSuiTransaction?: (txToSign: SuiSignTx, callbacks: SuiTransactionExecutionProps) => Promise<string>;
|
|
463
502
|
};
|
|
464
503
|
export type SwapperApi = {
|
|
465
504
|
checkTradeStatus: (input: CheckTradeStatusInput) => Promise<TradeStatus>;
|
|
@@ -471,10 +510,14 @@ export type SwapperApi = {
|
|
|
471
510
|
getUnsignedUtxoTransaction?: (input: GetUnsignedUtxoTransactionArgs) => Promise<SignTx<UtxoChainId>>;
|
|
472
511
|
getUnsignedCosmosSdkTransaction?: (input: GetUnsignedCosmosSdkTransactionArgs) => Promise<SignTx<CosmosSdkChainId>>;
|
|
473
512
|
getUnsignedSolanaTransaction?: (input: GetUnsignedSolanaTransactionArgs) => Promise<SolanaSignTx>;
|
|
513
|
+
getUnsignedTronTransaction?: (input: GetUnsignedTronTransactionArgs) => Promise<tron.TronSignTx>;
|
|
514
|
+
getUnsignedSuiTransaction?: (input: GetUnsignedSuiTransactionArgs) => Promise<SuiSignTx>;
|
|
474
515
|
getEvmTransactionFees?: (input: GetUnsignedEvmTransactionArgs) => Promise<string>;
|
|
475
516
|
getSolanaTransactionFees?: (input: GetUnsignedSolanaTransactionArgs) => Promise<string>;
|
|
517
|
+
getSuiTransactionFees?: (input: GetUnsignedSuiTransactionArgs) => Promise<string>;
|
|
476
518
|
getUtxoTransactionFees?: (input: GetUnsignedUtxoTransactionArgs) => Promise<string>;
|
|
477
519
|
getCosmosSdkTransactionFees?: (input: GetUnsignedCosmosSdkTransactionArgs) => Promise<string>;
|
|
520
|
+
getTronTransactionFees?: (input: GetUnsignedTronTransactionArgs) => Promise<string>;
|
|
478
521
|
};
|
|
479
522
|
export type QuoteResult = Result<TradeQuote[], SwapErrorRight> & {
|
|
480
523
|
swapperName: SwapperName;
|
|
@@ -497,6 +540,8 @@ export type EvmMessageExecutionInput = CommonTradeExecutionInput & EvmMessageExe
|
|
|
497
540
|
export type UtxoTransactionExecutionInput = CommonTradeExecutionInput & UtxoTransactionExecutionProps & UtxoAccountMetadata;
|
|
498
541
|
export type CosmosSdkTransactionExecutionInput = CommonTradeExecutionInput & CosmosSdkTransactionExecutionProps & CosmosSdkAccountMetadata;
|
|
499
542
|
export type SolanaTransactionExecutionInput = CommonTradeExecutionInput & SolanaTransactionExecutionProps & SolanaAccountMetadata;
|
|
543
|
+
export type TronTransactionExecutionInput = CommonTradeExecutionInput & TronTransactionExecutionProps & TronAccountMetadata;
|
|
544
|
+
export type SuiTransactionExecutionInput = CommonTradeExecutionInput & SuiTransactionExecutionProps & SuiAccountMetadata;
|
|
500
545
|
export declare enum TradeExecutionEvent {
|
|
501
546
|
SellTxHash = "sellTxHash",
|
|
502
547
|
RelayerTxHash = "relayerTxHash",
|
package/dist/cjs/types.js
CHANGED
|
@@ -16,6 +16,7 @@ var SwapperName;
|
|
|
16
16
|
SwapperName["ButterSwap"] = "ButterSwap";
|
|
17
17
|
SwapperName["Bebop"] = "Bebop";
|
|
18
18
|
SwapperName["NearIntents"] = "NEAR Intents";
|
|
19
|
+
SwapperName["Cetus"] = "Cetus";
|
|
19
20
|
})(SwapperName || (exports.SwapperName = SwapperName = {}));
|
|
20
21
|
var TradeQuoteError;
|
|
21
22
|
(function (TradeQuoteError) {
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
2
|
-
import type { EvmChainAdapter, SignTx, solana } from '@shapeshiftoss/chain-adapters';
|
|
3
|
-
import type { SolanaSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
2
|
+
import type { EvmChainAdapter, SignTx, solana, sui } from '@shapeshiftoss/chain-adapters';
|
|
3
|
+
import type { SolanaSignTx, SuiSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
4
4
|
import type { Asset, EvmChainId } from '@shapeshiftoss/types';
|
|
5
5
|
import { TxStatus } from '@shapeshiftoss/unchained-client';
|
|
6
6
|
import type { Result } from '@sniptt/monads';
|
|
7
7
|
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TronSignTx } from 'packages/chain-adapters/src/tron/types';
|
|
9
|
+
import type { EvmTransactionExecutionProps, ExecutableTradeStep, SolanaTransactionExecutionProps, SuiTransactionExecutionProps, SupportedTradeQuoteStepIndex, SwapErrorRight, TradeQuote, TradeQuoteStep, TradeRate, TradeStatus, TronTransactionExecutionProps } from './types';
|
|
9
10
|
import { TradeQuoteError } from './types';
|
|
10
11
|
export declare const makeSwapErrorRight: ({ details, cause, code, message, }: {
|
|
11
12
|
message: string;
|
|
@@ -27,6 +28,8 @@ export declare const makeSwapperAxiosServiceMonadic: (service: AxiosInstance) =>
|
|
|
27
28
|
export declare const getHopByIndex: (quote: TradeQuote | TradeRate | undefined, index: SupportedTradeQuoteStepIndex) => TradeQuoteStep | undefined;
|
|
28
29
|
export declare const executeEvmTransaction: (txToSign: SignTx<EvmChainId>, callbacks: EvmTransactionExecutionProps) => Promise<string>;
|
|
29
30
|
export declare const executeSolanaTransaction: (txToSign: SolanaSignTx, callbacks: SolanaTransactionExecutionProps) => Promise<string>;
|
|
31
|
+
export declare const executeTronTransaction: (txToSign: TronSignTx, callbacks: TronTransactionExecutionProps) => Promise<string>;
|
|
32
|
+
export declare const executeSuiTransaction: (txToSign: SuiSignTx, callbacks: SuiTransactionExecutionProps) => Promise<string>;
|
|
30
33
|
export declare const createDefaultStatusResponse: (buyTxHash?: string) => {
|
|
31
34
|
status: TxStatus;
|
|
32
35
|
buyTxHash: string | undefined;
|
|
@@ -60,3 +63,8 @@ export declare const checkSolanaSwapStatus: ({ txHash, address, assertGetSolanaC
|
|
|
60
63
|
address: string | undefined;
|
|
61
64
|
assertGetSolanaChainAdapter: (chainId: ChainId) => solana.ChainAdapter;
|
|
62
65
|
}) => Promise<TradeStatus>;
|
|
66
|
+
export declare const checkSuiSwapStatus: ({ txHash, address, assertGetSuiChainAdapter, }: {
|
|
67
|
+
txHash: string;
|
|
68
|
+
address: string | undefined;
|
|
69
|
+
assertGetSuiChainAdapter: (chainId: ChainId) => sui.ChainAdapter;
|
|
70
|
+
}) => Promise<TradeStatus>;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.checkSolanaSwapStatus = exports.getExecutableTradeStep = exports.isExecutableTradeStep = exports.isExecutableTradeQuote = exports.getInputOutputRate = exports.checkEvmSwapStatus = exports.checkSafeTransactionStatus = exports.createDefaultStatusResponse = exports.executeSolanaTransaction = exports.executeEvmTransaction = exports.getHopByIndex = exports.makeSwapperAxiosServiceMonadic = exports.AsyncResultOf = exports.createCache = exports.createTradeAmountTooSmallErr = exports.makeSwapErrorRight = void 0;
|
|
6
|
+
exports.checkSuiSwapStatus = exports.checkSolanaSwapStatus = exports.getExecutableTradeStep = exports.isExecutableTradeStep = exports.isExecutableTradeQuote = exports.getInputOutputRate = exports.checkEvmSwapStatus = exports.checkSafeTransactionStatus = exports.createDefaultStatusResponse = exports.executeSuiTransaction = exports.executeTronTransaction = exports.executeSolanaTransaction = exports.executeEvmTransaction = exports.getHopByIndex = exports.makeSwapperAxiosServiceMonadic = exports.AsyncResultOf = exports.createCache = exports.createTradeAmountTooSmallErr = exports.makeSwapErrorRight = void 0;
|
|
7
7
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
8
|
const unchained_client_1 = require("@shapeshiftoss/unchained-client");
|
|
9
9
|
const utils_1 = require("@shapeshiftoss/utils");
|
|
@@ -97,6 +97,14 @@ const executeSolanaTransaction = (txToSign, callbacks) => {
|
|
|
97
97
|
return callbacks.signAndBroadcastTransaction(txToSign);
|
|
98
98
|
};
|
|
99
99
|
exports.executeSolanaTransaction = executeSolanaTransaction;
|
|
100
|
+
const executeTronTransaction = (txToSign, callbacks) => {
|
|
101
|
+
return callbacks.signAndBroadcastTransaction(txToSign);
|
|
102
|
+
};
|
|
103
|
+
exports.executeTronTransaction = executeTronTransaction;
|
|
104
|
+
const executeSuiTransaction = (txToSign, callbacks) => {
|
|
105
|
+
return callbacks.signAndBroadcastTransaction(txToSign);
|
|
106
|
+
};
|
|
107
|
+
exports.executeSuiTransaction = executeSuiTransaction;
|
|
100
108
|
const createDefaultStatusResponse = (buyTxHash) => ({
|
|
101
109
|
status: unchained_client_1.TxStatus.Unknown,
|
|
102
110
|
buyTxHash,
|
|
@@ -203,3 +211,28 @@ const checkSolanaSwapStatus = async ({ txHash, address, assertGetSolanaChainAdap
|
|
|
203
211
|
}
|
|
204
212
|
};
|
|
205
213
|
exports.checkSolanaSwapStatus = checkSolanaSwapStatus;
|
|
214
|
+
const checkSuiSwapStatus = async ({ txHash, address, assertGetSuiChainAdapter, }) => {
|
|
215
|
+
try {
|
|
216
|
+
if (!address)
|
|
217
|
+
throw new Error('Missing address');
|
|
218
|
+
const adapter = assertGetSuiChainAdapter(caip_1.suiChainId);
|
|
219
|
+
const client = adapter.getSuiClient();
|
|
220
|
+
const txResponse = await client.getTransactionBlock({
|
|
221
|
+
digest: txHash,
|
|
222
|
+
options: {
|
|
223
|
+
showEffects: true,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
const status = txResponse.effects?.status?.status === 'success' ? unchained_client_1.TxStatus.Confirmed : unchained_client_1.TxStatus.Failed;
|
|
227
|
+
return {
|
|
228
|
+
status,
|
|
229
|
+
buyTxHash: txHash,
|
|
230
|
+
message: undefined,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
catch (e) {
|
|
234
|
+
console.error(e);
|
|
235
|
+
return (0, exports.createDefaultStatusResponse)(txHash);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.checkSuiSwapStatus = checkSuiSwapStatus;
|