@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
package/dist/esm/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.js';
|
|
15
15
|
import type { RelayTransactionMetadata } from './swappers/RelaySwapper/utils/types.js';
|
|
@@ -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/esm/types.js
CHANGED
|
@@ -13,6 +13,7 @@ export var SwapperName;
|
|
|
13
13
|
SwapperName["ButterSwap"] = "ButterSwap";
|
|
14
14
|
SwapperName["Bebop"] = "Bebop";
|
|
15
15
|
SwapperName["NearIntents"] = "NEAR Intents";
|
|
16
|
+
SwapperName["Cetus"] = "Cetus";
|
|
16
17
|
})(SwapperName || (SwapperName = {}));
|
|
17
18
|
export var TradeQuoteError;
|
|
18
19
|
(function (TradeQuoteError) {
|
package/dist/esm/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.js';
|
|
9
10
|
import { TradeQuoteError } from './types.js';
|
|
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/esm/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { solanaChainId } from '@shapeshiftoss/caip';
|
|
1
|
+
import { solanaChainId, suiChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { evm, TxStatus } from '@shapeshiftoss/unchained-client';
|
|
3
3
|
import { bn, fromBaseUnit } from '@shapeshiftoss/utils';
|
|
4
4
|
import { Err, Ok } from '@sniptt/monads';
|
|
@@ -83,6 +83,12 @@ export const executeEvmTransaction = (txToSign, callbacks) => {
|
|
|
83
83
|
export const executeSolanaTransaction = (txToSign, callbacks) => {
|
|
84
84
|
return callbacks.signAndBroadcastTransaction(txToSign);
|
|
85
85
|
};
|
|
86
|
+
export const executeTronTransaction = (txToSign, callbacks) => {
|
|
87
|
+
return callbacks.signAndBroadcastTransaction(txToSign);
|
|
88
|
+
};
|
|
89
|
+
export const executeSuiTransaction = (txToSign, callbacks) => {
|
|
90
|
+
return callbacks.signAndBroadcastTransaction(txToSign);
|
|
91
|
+
};
|
|
86
92
|
export const createDefaultStatusResponse = (buyTxHash) => ({
|
|
87
93
|
status: TxStatus.Unknown,
|
|
88
94
|
buyTxHash,
|
|
@@ -181,3 +187,27 @@ export const checkSolanaSwapStatus = async ({ txHash, address, assertGetSolanaCh
|
|
|
181
187
|
return createDefaultStatusResponse(txHash);
|
|
182
188
|
}
|
|
183
189
|
};
|
|
190
|
+
export const checkSuiSwapStatus = async ({ txHash, address, assertGetSuiChainAdapter, }) => {
|
|
191
|
+
try {
|
|
192
|
+
if (!address)
|
|
193
|
+
throw new Error('Missing address');
|
|
194
|
+
const adapter = assertGetSuiChainAdapter(suiChainId);
|
|
195
|
+
const client = adapter.getSuiClient();
|
|
196
|
+
const txResponse = await client.getTransactionBlock({
|
|
197
|
+
digest: txHash,
|
|
198
|
+
options: {
|
|
199
|
+
showEffects: true,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
const status = txResponse.effects?.status?.status === 'success' ? TxStatus.Confirmed : TxStatus.Failed;
|
|
203
|
+
return {
|
|
204
|
+
status,
|
|
205
|
+
buyTxHash: txHash,
|
|
206
|
+
message: undefined,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
console.error(e);
|
|
211
|
+
return createDefaultStatusResponse(txHash);
|
|
212
|
+
}
|
|
213
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/swapper",
|
|
3
|
-
"version": "17.6.
|
|
3
|
+
"version": "17.6.7",
|
|
4
4
|
"packageManager": "yarn@3.5.0",
|
|
5
5
|
"repository": "https://github.com/shapeshift/web",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"@cowprotocol/app-data": "^2.3.0",
|
|
36
36
|
"@defuse-protocol/one-click-sdk-typescript": "^0.1.1-0.2",
|
|
37
37
|
"@jup-ag/api": "^6.0.30",
|
|
38
|
-
"@shapeshiftoss/bitcoinjs-lib": "
|
|
39
|
-
"@shapeshiftoss/caip": "^8.16.
|
|
40
|
-
"@shapeshiftoss/chain-adapters": "^11.3.
|
|
41
|
-
"@shapeshiftoss/contracts": "^1.0.
|
|
42
|
-
"@shapeshiftoss/hdwallet-core": "1.62.
|
|
43
|
-
"@shapeshiftoss/types": "^8.6.
|
|
44
|
-
"@shapeshiftoss/unchained-client": "^10.14.
|
|
45
|
-
"@shapeshiftoss/utils": "^1.0.
|
|
38
|
+
"@shapeshiftoss/bitcoinjs-lib": "7.0.0-shapeshift.0",
|
|
39
|
+
"@shapeshiftoss/caip": "^8.16.5",
|
|
40
|
+
"@shapeshiftoss/chain-adapters": "^11.3.6",
|
|
41
|
+
"@shapeshiftoss/contracts": "^1.0.4",
|
|
42
|
+
"@shapeshiftoss/hdwallet-core": "1.62.21",
|
|
43
|
+
"@shapeshiftoss/types": "^8.6.5",
|
|
44
|
+
"@shapeshiftoss/unchained-client": "^10.14.8",
|
|
45
|
+
"@shapeshiftoss/utils": "^1.0.4",
|
|
46
46
|
"@sniptt/monads": "^0.5.10",
|
|
47
47
|
"@solana/web3.js": "^1.98.0",
|
|
48
48
|
"@uniswap/sdk-core": "^5.3.1",
|
|
@@ -60,6 +60,13 @@
|
|
|
60
60
|
"qs": "^6.10.5",
|
|
61
61
|
"retry-axios": "^2.6.0",
|
|
62
62
|
"uuid": "^9.0.0",
|
|
63
|
-
"viem": "^2.
|
|
63
|
+
"viem": "^2.40.3"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/lodash": "^4.14.178",
|
|
67
|
+
"@types/mixpanel-browser": "^2.38.1",
|
|
68
|
+
"@types/node-polyglot": "^2.4.2",
|
|
69
|
+
"@types/qs": "^6.9.18",
|
|
70
|
+
"@types/uuid": "^9.0.5"
|
|
64
71
|
}
|
|
65
72
|
}
|