@shapeshiftoss/swapper 11.5.4 → 11.5.6
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 +7 -0
- package/dist/api.js +9 -1
- package/dist/swappers/cow/CowSwapper.d.ts +2 -2
- package/dist/swappers/cow/CowSwapper.js +1 -1
- package/dist/swappers/osmosis/OsmosisSwapper.d.ts +2 -2
- package/dist/swappers/osmosis/OsmosisSwapper.js +1 -1
- package/dist/swappers/test/TestSwapper.d.ts +2 -2
- package/dist/swappers/test/TestSwapper.js +1 -1
- package/dist/swappers/thorchain/ThorchainSwapper.d.ts +2 -2
- package/dist/swappers/thorchain/ThorchainSwapper.js +10 -7
- package/dist/swappers/zrx/ZrxSwapper.d.ts +2 -2
- package/dist/swappers/zrx/ZrxSwapper.js +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -156,6 +156,13 @@ export interface MinMaxOutput {
|
|
|
156
156
|
export declare type ApprovalNeededOutput = {
|
|
157
157
|
approvalNeeded: boolean;
|
|
158
158
|
};
|
|
159
|
+
export declare enum SwapperName {
|
|
160
|
+
Thorchain = "THORChain",
|
|
161
|
+
Osmosis = "Osmosis",
|
|
162
|
+
CowSwap = "CowSwap",
|
|
163
|
+
Zrx = "0x",
|
|
164
|
+
Test = "Test"
|
|
165
|
+
}
|
|
159
166
|
export declare enum SwapperType {
|
|
160
167
|
ZrxEthereum = "0xEthereum",
|
|
161
168
|
ZrxAvalanche = "0xAvalanche",
|
package/dist/api.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SwapErrorTypes = exports.SwapperType = exports.SwapError = void 0;
|
|
3
|
+
exports.SwapErrorTypes = exports.SwapperType = exports.SwapperName = exports.SwapError = void 0;
|
|
4
4
|
const errors_1 = require("@shapeshiftoss/errors");
|
|
5
5
|
const types_1 = require("@shapeshiftoss/types");
|
|
6
6
|
exports.SwapError = (0, errors_1.createErrorClass)('SwapError');
|
|
7
|
+
var SwapperName;
|
|
8
|
+
(function (SwapperName) {
|
|
9
|
+
SwapperName["Thorchain"] = "THORChain";
|
|
10
|
+
SwapperName["Osmosis"] = "Osmosis";
|
|
11
|
+
SwapperName["CowSwap"] = "CowSwap";
|
|
12
|
+
SwapperName["Zrx"] = "0x";
|
|
13
|
+
SwapperName["Test"] = "Test";
|
|
14
|
+
})(SwapperName = exports.SwapperName || (exports.SwapperName = {}));
|
|
7
15
|
var SwapperType;
|
|
8
16
|
(function (SwapperType) {
|
|
9
17
|
SwapperType["ZrxEthereum"] = "0xEthereum";
|
|
@@ -3,7 +3,7 @@ import { AssetId } from '@shapeshiftoss/caip';
|
|
|
3
3
|
import { ethereum } from '@shapeshiftoss/chain-adapters';
|
|
4
4
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
5
5
|
import Web3 from 'web3';
|
|
6
|
-
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveAmountInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
6
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveAmountInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, SwapperName, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
7
7
|
import { CowTrade } from './types';
|
|
8
8
|
export declare type CowSwapperDeps = {
|
|
9
9
|
apiUrl: string;
|
|
@@ -11,7 +11,7 @@ export declare type CowSwapperDeps = {
|
|
|
11
11
|
web3: Web3;
|
|
12
12
|
};
|
|
13
13
|
export declare class CowSwapper implements Swapper<KnownChainIds.EthereumMainnet> {
|
|
14
|
-
readonly name =
|
|
14
|
+
readonly name = SwapperName.CowSwap;
|
|
15
15
|
deps: CowSwapperDeps;
|
|
16
16
|
constructor(deps: CowSwapperDeps);
|
|
17
17
|
getType(): SwapperType;
|
|
@@ -28,7 +28,7 @@ const blacklist_1 = require("./utils/blacklist");
|
|
|
28
28
|
const helpers_1 = require("./utils/helpers/helpers");
|
|
29
29
|
class CowSwapper {
|
|
30
30
|
constructor(deps) {
|
|
31
|
-
this.name =
|
|
31
|
+
this.name = api_1.SwapperName.CowSwap;
|
|
32
32
|
this.deps = deps;
|
|
33
33
|
}
|
|
34
34
|
getType() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import { ApprovalNeededOutput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeTxs } from '../../api';
|
|
3
|
+
import { ApprovalNeededOutput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperName, SwapperType, Trade, TradeQuote, TradeTxs } from '../../api';
|
|
4
4
|
import { OsmosisTradeResult, OsmoSwapperDeps } from './utils/types';
|
|
5
5
|
export declare class OsmosisSwapper implements Swapper<ChainId> {
|
|
6
|
-
readonly name =
|
|
6
|
+
readonly name = SwapperName.Osmosis;
|
|
7
7
|
supportedAssetIds: string[];
|
|
8
8
|
deps: OsmoSwapperDeps;
|
|
9
9
|
getType(): SwapperType;
|
|
@@ -8,7 +8,7 @@ const constants_1 = require("./utils/constants");
|
|
|
8
8
|
const helpers_1 = require("./utils/helpers");
|
|
9
9
|
class OsmosisSwapper {
|
|
10
10
|
constructor(deps) {
|
|
11
|
-
this.name =
|
|
11
|
+
this.name = api_1.SwapperName.Osmosis;
|
|
12
12
|
this.deps = deps;
|
|
13
13
|
this.supportedAssetIds = [caip_1.cosmosAssetId, caip_1.osmosisAssetId];
|
|
14
14
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import { ApprovalNeededOutput, BuyAssetBySellIdInput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
3
|
+
import { ApprovalNeededOutput, BuyAssetBySellIdInput, Swapper, SwapperName, 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
|
|
7
7
|
*/
|
|
8
8
|
export declare class TestSwapper implements Swapper<ChainId> {
|
|
9
|
-
readonly name =
|
|
9
|
+
readonly name = SwapperName.Test;
|
|
10
10
|
supportAssets: string[];
|
|
11
11
|
initialize(): Promise<void>;
|
|
12
12
|
getType(): SwapperType;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
3
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
4
|
-
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, SwapperName, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
5
5
|
import { ThorchainSwapperDeps } from './types';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export declare class ThorchainSwapper implements Swapper<ChainId> {
|
|
8
|
-
readonly name =
|
|
8
|
+
readonly name = SwapperName.Thorchain;
|
|
9
9
|
private sellSupportedChainIds;
|
|
10
10
|
private buySupportedChainIds;
|
|
11
11
|
private supportedSellAssetIds;
|
|
@@ -27,7 +27,7 @@ const thorService_1 = require("./utils/thorService");
|
|
|
27
27
|
__exportStar(require("./types"), exports);
|
|
28
28
|
class ThorchainSwapper {
|
|
29
29
|
constructor(deps) {
|
|
30
|
-
this.name =
|
|
30
|
+
this.name = api_1.SwapperName.Thorchain;
|
|
31
31
|
this.sellSupportedChainIds = {
|
|
32
32
|
[types_1.KnownChainIds.EthereumMainnet]: true,
|
|
33
33
|
[types_1.KnownChainIds.BitcoinMainnet]: true,
|
|
@@ -119,12 +119,15 @@ class ThorchainSwapper {
|
|
|
119
119
|
});
|
|
120
120
|
const { chainNamespace } = (0, caip_1.fromAssetId)(trade.sellAsset.assetId);
|
|
121
121
|
if (chainNamespace === caip_1.CHAIN_NAMESPACE.Evm) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
const evmAdapter = adapter;
|
|
123
|
+
const txToSign = trade.txData;
|
|
124
|
+
if (wallet.supportsBroadcast()) {
|
|
125
|
+
const tradeId = await evmAdapter.signAndBroadcastTransaction({ txToSign, wallet });
|
|
126
|
+
return { tradeId };
|
|
127
|
+
}
|
|
128
|
+
const signedTx = await evmAdapter.signTransaction({ txToSign, wallet });
|
|
129
|
+
const tradeId = await adapter.broadcastTransaction(signedTx);
|
|
130
|
+
return { tradeId };
|
|
128
131
|
}
|
|
129
132
|
else if (chainNamespace === caip_1.CHAIN_NAMESPACE.Utxo) {
|
|
130
133
|
const signedTx = await adapter.signTransaction({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Asset } from '@shapeshiftoss/asset-service';
|
|
2
2
|
import { AssetId, ChainId } from '@shapeshiftoss/caip';
|
|
3
|
-
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveAmountInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, EvmSupportedChainIds, GetEvmTradeQuoteInput, Swapper, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
3
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveAmountInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, EvmSupportedChainIds, GetEvmTradeQuoteInput, Swapper, SwapperName, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
4
|
import { ZrxExecuteTradeInput, ZrxSwapperDeps, ZrxTrade } from './types';
|
|
5
5
|
export declare class ZrxSwapper<T extends EvmSupportedChainIds> implements Swapper<T> {
|
|
6
|
-
readonly name =
|
|
6
|
+
readonly name = SwapperName.Zrx;
|
|
7
7
|
deps: ZrxSwapperDeps;
|
|
8
8
|
chainId: ChainId;
|
|
9
9
|
constructor(deps: ZrxSwapperDeps);
|
|
@@ -12,7 +12,7 @@ const zrxBuildTrade_1 = require("./zrxBuildTrade/zrxBuildTrade");
|
|
|
12
12
|
const zrxExecuteTrade_1 = require("./zrxExecuteTrade/zrxExecuteTrade");
|
|
13
13
|
class ZrxSwapper {
|
|
14
14
|
constructor(deps) {
|
|
15
|
-
this.name =
|
|
15
|
+
this.name = api_1.SwapperName.Zrx;
|
|
16
16
|
this.deps = deps;
|
|
17
17
|
this.chainId = deps.adapter.getChainId();
|
|
18
18
|
}
|
package/package.json
CHANGED