@shapeshiftoss/swapper 5.2.1 → 5.2.2
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/api.d.ts +6 -1
- package/dist/swappers/test/TestSwapper.d.ts +2 -1
- package/dist/swappers/test/TestSwapper.js +3 -0
- package/dist/swappers/thorchain/ThorchainSwapper.d.ts +2 -1
- package/dist/swappers/thorchain/ThorchainSwapper.js +3 -0
- package/dist/swappers/zrx/ZrxSwapper.d.ts +2 -1
- package/dist/swappers/zrx/ZrxSwapper.js +6 -0
- package/dist/swappers/zrx/zrxExecuteTrade/zrxExecuteTrade.js +2 -2
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export declare type ExecuteTradeInput<C extends SupportedChainIds> = {
|
|
|
90
90
|
wallet: HDWallet;
|
|
91
91
|
};
|
|
92
92
|
export declare type TradeResult = {
|
|
93
|
-
|
|
93
|
+
tradeId: string;
|
|
94
94
|
};
|
|
95
95
|
export declare type ApproveInfiniteInput<C extends SupportedChainIds> = {
|
|
96
96
|
quote: TradeQuote<C>;
|
|
@@ -122,6 +122,10 @@ export declare enum SwapperType {
|
|
|
122
122
|
Thorchain = "Thorchain",
|
|
123
123
|
Test = "Test"
|
|
124
124
|
}
|
|
125
|
+
export declare type TradeTxs = {
|
|
126
|
+
sellTxid: string;
|
|
127
|
+
buyTxid?: string;
|
|
128
|
+
};
|
|
125
129
|
export declare enum SwapErrorTypes {
|
|
126
130
|
ALLOWANCE_REQUIRED_FAILED = "ALLOWANCE_REQUIRED_FAILED",
|
|
127
131
|
APPROVE_INFINITE_FAILED = "APPROVE_INFINITE_FAILED",
|
|
@@ -180,5 +184,6 @@ export interface Swapper {
|
|
|
180
184
|
* Get supported sell assetIds
|
|
181
185
|
*/
|
|
182
186
|
filterAssetIdsBySellable(assetIds: AssetId[]): AssetId[];
|
|
187
|
+
getTradeTxs(tradeResult: TradeResult): Promise<TradeTxs>;
|
|
183
188
|
}
|
|
184
189
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
-
import { ApprovalNeededOutput, BuyAssetBySellIdInput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult } from '../../api';
|
|
3
|
+
import { ApprovalNeededOutput, BuyAssetBySellIdInput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
4
|
/**
|
|
5
5
|
* Playground for testing different scenarios of multiple swappers in the manager.
|
|
6
6
|
* Meant for local testing only
|
|
@@ -19,4 +19,5 @@ export declare class TestSwapper implements Swapper {
|
|
|
19
19
|
buildTrade(): Promise<Trade<SupportedChainIds>>;
|
|
20
20
|
getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
|
|
21
21
|
executeTrade(): Promise<TradeResult>;
|
|
22
|
+
getTradeTxs(): Promise<TradeTxs>;
|
|
22
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
-
import { ApprovalNeededOutput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult } from '../../api';
|
|
3
|
+
import { ApprovalNeededOutput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
4
|
export declare class ThorchainSwapper implements Swapper {
|
|
5
5
|
getType(): SwapperType;
|
|
6
6
|
initialize(): Promise<void>;
|
|
@@ -13,4 +13,5 @@ export declare class ThorchainSwapper implements Swapper {
|
|
|
13
13
|
buildTrade(): Promise<Trade<SupportedChainIds>>;
|
|
14
14
|
getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
|
|
15
15
|
executeTrade(): Promise<TradeResult>;
|
|
16
|
+
getTradeTxs(): Promise<TradeTxs>;
|
|
16
17
|
}
|
|
@@ -38,5 +38,8 @@ class ThorchainSwapper {
|
|
|
38
38
|
async executeTrade() {
|
|
39
39
|
throw new Error('ThorchainSwapper: executeTrade unimplemented');
|
|
40
40
|
}
|
|
41
|
+
async getTradeTxs() {
|
|
42
|
+
throw new Error('ThorchainSwapper: executeTrade unimplemented');
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
exports.ThorchainSwapper = ThorchainSwapper;
|
|
@@ -2,7 +2,7 @@ import { AssetId } from '@shapeshiftoss/caip';
|
|
|
2
2
|
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
3
3
|
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
4
4
|
import Web3 from 'web3';
|
|
5
|
-
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetMinMaxInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperType, TradeQuote, TradeResult, ZrxTrade } from '../../api';
|
|
5
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetMinMaxInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperType, TradeQuote, TradeResult, TradeTxs, ZrxTrade } from '../../api';
|
|
6
6
|
export declare type ZrxSwapperDeps = {
|
|
7
7
|
adapterManager: ChainAdapterManager;
|
|
8
8
|
web3: Web3;
|
|
@@ -22,4 +22,5 @@ export declare class ZrxSwapper implements Swapper {
|
|
|
22
22
|
approveInfinite(args: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
|
|
23
23
|
filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
|
|
24
24
|
filterAssetIdsBySellable(assetIds?: AssetId[]): AssetId[];
|
|
25
|
+
getTradeTxs(tradeResult: TradeResult): Promise<TradeTxs>;
|
|
25
26
|
}
|
|
@@ -50,6 +50,12 @@ class ZrxSwapper {
|
|
|
50
50
|
filterAssetIdsBySellable(assetIds = []) {
|
|
51
51
|
return assetIds.filter((id) => id.startsWith('eip155:1') && !blacklist_1.UNSUPPORTED_ASSETS.includes(id));
|
|
52
52
|
}
|
|
53
|
+
async getTradeTxs(tradeResult) {
|
|
54
|
+
return {
|
|
55
|
+
sellTxid: tradeResult.tradeId,
|
|
56
|
+
buyTxid: tradeResult.tradeId
|
|
57
|
+
};
|
|
58
|
+
}
|
|
53
59
|
}
|
|
54
60
|
exports.ZrxSwapper = ZrxSwapper;
|
|
55
61
|
ZrxSwapper.swapperName = 'ZrxSwapper';
|
|
@@ -30,14 +30,14 @@ async function zrxExecuteTrade({ adapterManager }, { trade, wallet }) {
|
|
|
30
30
|
if (wallet.supportsOfflineSigning()) {
|
|
31
31
|
const signedTx = await adapter.signTransaction({ txToSign: txWithQuoteData, wallet });
|
|
32
32
|
const txid = await adapter.broadcastTransaction(signedTx);
|
|
33
|
-
return { txid };
|
|
33
|
+
return { tradeId: txid };
|
|
34
34
|
}
|
|
35
35
|
else if (wallet.supportsBroadcast() && adapter.signAndBroadcastTransaction) {
|
|
36
36
|
const txid = await ((_f = adapter.signAndBroadcastTransaction) === null || _f === void 0 ? void 0 : _f.call(adapter, {
|
|
37
37
|
txToSign: txWithQuoteData,
|
|
38
38
|
wallet
|
|
39
39
|
}));
|
|
40
|
-
return { txid };
|
|
40
|
+
return { tradeId: txid };
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
throw new api_1.SwapError('[zrxExecuteTrade]', {
|