@shapeshiftoss/swapper 5.2.0 → 5.2.1
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 +24 -6
- package/dist/api.js +7 -1
- package/dist/manager/SwapperManager.d.ts +1 -1
- package/dist/swappercli.js +2 -1
- package/dist/swappers/test/TestSwapper.d.ts +3 -3
- package/dist/swappers/test/TestSwapper.js +2 -2
- package/dist/swappers/thorchain/ThorchainSwapper.d.ts +3 -3
- package/dist/swappers/thorchain/ThorchainSwapper.js +2 -2
- package/dist/swappers/zrx/ZrxApprovalNeeded/ZrxApprovalNeeded.d.ts +2 -2
- package/dist/swappers/zrx/ZrxSwapper.d.ts +3 -3
- package/dist/swappers/zrx/ZrxSwapper.js +2 -2
- package/dist/swappers/zrx/getZrxMinMax/getZrxMinMax.d.ts +2 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
3
|
-
import {
|
|
3
|
+
import { Asset, ChainSpecific, SupportedChainIds } from '@shapeshiftoss/types';
|
|
4
4
|
export declare const SwapError: {
|
|
5
5
|
new <V extends {
|
|
6
6
|
cause?: unknown;
|
|
@@ -92,10 +92,6 @@ export declare type ExecuteTradeInput<C extends SupportedChainIds> = {
|
|
|
92
92
|
export declare type TradeResult = {
|
|
93
93
|
txid: string;
|
|
94
94
|
};
|
|
95
|
-
export declare type SwapSource = {
|
|
96
|
-
name: string;
|
|
97
|
-
proportion: string;
|
|
98
|
-
};
|
|
99
95
|
export declare type ApproveInfiniteInput<C extends SupportedChainIds> = {
|
|
100
96
|
quote: TradeQuote<C>;
|
|
101
97
|
wallet: HDWallet;
|
|
@@ -104,6 +100,28 @@ export declare type ApprovalNeededInput<C extends SupportedChainIds> = {
|
|
|
104
100
|
quote: TradeQuote<C>;
|
|
105
101
|
wallet: HDWallet;
|
|
106
102
|
};
|
|
103
|
+
export declare type SwapSource = {
|
|
104
|
+
name: string;
|
|
105
|
+
proportion: string;
|
|
106
|
+
};
|
|
107
|
+
export interface MinMaxOutput {
|
|
108
|
+
minimum: string;
|
|
109
|
+
maximum: string;
|
|
110
|
+
}
|
|
111
|
+
export declare type GetMinMaxInput = {
|
|
112
|
+
sellAsset: Asset;
|
|
113
|
+
buyAsset: Asset;
|
|
114
|
+
};
|
|
115
|
+
export declare type ApprovalNeededOutput = {
|
|
116
|
+
approvalNeeded: boolean;
|
|
117
|
+
gas?: string;
|
|
118
|
+
gasPrice?: string;
|
|
119
|
+
};
|
|
120
|
+
export declare enum SwapperType {
|
|
121
|
+
Zrx = "0x",
|
|
122
|
+
Thorchain = "Thorchain",
|
|
123
|
+
Test = "Test"
|
|
124
|
+
}
|
|
107
125
|
export declare enum SwapErrorTypes {
|
|
108
126
|
ALLOWANCE_REQUIRED_FAILED = "ALLOWANCE_REQUIRED_FAILED",
|
|
109
127
|
APPROVE_INFINITE_FAILED = "APPROVE_INFINITE_FAILED",
|
|
@@ -145,7 +163,7 @@ export interface Swapper {
|
|
|
145
163
|
/**
|
|
146
164
|
* Execute a trade built with buildTrade by signing and broadcasting
|
|
147
165
|
*/
|
|
148
|
-
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<
|
|
166
|
+
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<TradeResult>;
|
|
149
167
|
/**
|
|
150
168
|
* Get a boolean if a quote needs approval
|
|
151
169
|
*/
|
package/dist/api.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SwapErrorTypes = exports.SwapError = void 0;
|
|
3
|
+
exports.SwapErrorTypes = exports.SwapperType = exports.SwapError = void 0;
|
|
4
4
|
const errors_1 = require("@shapeshiftoss/errors");
|
|
5
5
|
exports.SwapError = (0, errors_1.createErrorClass)('SwapError');
|
|
6
|
+
var SwapperType;
|
|
7
|
+
(function (SwapperType) {
|
|
8
|
+
SwapperType["Zrx"] = "0x";
|
|
9
|
+
SwapperType["Thorchain"] = "Thorchain";
|
|
10
|
+
SwapperType["Test"] = "Test";
|
|
11
|
+
})(SwapperType = exports.SwapperType || (exports.SwapperType = {}));
|
|
6
12
|
// Swap Errors
|
|
7
13
|
var SwapErrorTypes;
|
|
8
14
|
(function (SwapErrorTypes) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SwapperType } from '@shapeshiftoss/types';
|
|
2
1
|
import { BuyAssetBySellIdInput, ByPairInput, SupportedSellAssetsInput, Swapper } from '..';
|
|
2
|
+
import { SwapperType } from '../api';
|
|
3
3
|
export declare class SwapperManager {
|
|
4
4
|
swappers: Map<SwapperType, Swapper>;
|
|
5
5
|
constructor();
|
package/dist/swappercli.js
CHANGED
|
@@ -11,6 +11,7 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
|
11
11
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
12
12
|
const readline_sync_1 = __importDefault(require("readline-sync"));
|
|
13
13
|
const web3_1 = __importDefault(require("web3"));
|
|
14
|
+
const api_1 = require("./api");
|
|
14
15
|
const SwapperManager_1 = require("./manager/SwapperManager");
|
|
15
16
|
const ZrxSwapper_1 = require("./swappers/zrx/ZrxSwapper");
|
|
16
17
|
dotenv_1.default.config();
|
|
@@ -83,7 +84,7 @@ const main = async () => {
|
|
|
83
84
|
const zrxSwapperDeps = { wallet, adapterManager, web3 };
|
|
84
85
|
const manager = new SwapperManager_1.SwapperManager();
|
|
85
86
|
const zrxSwapper = new ZrxSwapper_1.ZrxSwapper(zrxSwapperDeps);
|
|
86
|
-
manager.addSwapper(
|
|
87
|
+
manager.addSwapper(api_1.SwapperType.Zrx, zrxSwapper);
|
|
87
88
|
const swapper = await manager.getBestSwapper({
|
|
88
89
|
sellAssetId: 'eip155:1/slip44:60',
|
|
89
90
|
buyAssetId: 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
-
import {
|
|
3
|
-
import { BuyAssetBySellIdInput, Swapper, Trade, TradeQuote } from '../../api';
|
|
2
|
+
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
+
import { ApprovalNeededOutput, BuyAssetBySellIdInput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult } from '../../api';
|
|
4
4
|
/**
|
|
5
5
|
* Playground for testing different scenarios of multiple swappers in the manager.
|
|
6
6
|
* Meant for local testing only
|
|
@@ -18,5 +18,5 @@ export declare class TestSwapper implements Swapper {
|
|
|
18
18
|
filterAssetIdsBySellable(): AssetId[];
|
|
19
19
|
buildTrade(): Promise<Trade<SupportedChainIds>>;
|
|
20
20
|
getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
|
|
21
|
-
executeTrade(): Promise<
|
|
21
|
+
executeTrade(): Promise<TradeResult>;
|
|
22
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TestSwapper = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
5
|
/**
|
|
6
6
|
* Playground for testing different scenarios of multiple swappers in the manager.
|
|
7
7
|
* Meant for local testing only
|
|
@@ -18,7 +18,7 @@ class TestSwapper {
|
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
19
19
|
async initialize() { }
|
|
20
20
|
getType() {
|
|
21
|
-
return
|
|
21
|
+
return api_1.SwapperType.Test;
|
|
22
22
|
}
|
|
23
23
|
getUsdRate(input) {
|
|
24
24
|
console.info(input);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
-
import {
|
|
3
|
-
import { Swapper, Trade, TradeQuote } from '../../api';
|
|
2
|
+
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
+
import { ApprovalNeededOutput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult } from '../../api';
|
|
4
4
|
export declare class ThorchainSwapper implements Swapper {
|
|
5
5
|
getType(): SwapperType;
|
|
6
6
|
initialize(): Promise<void>;
|
|
@@ -12,5 +12,5 @@ export declare class ThorchainSwapper implements Swapper {
|
|
|
12
12
|
filterAssetIdsBySellable(): AssetId[];
|
|
13
13
|
buildTrade(): Promise<Trade<SupportedChainIds>>;
|
|
14
14
|
getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
|
|
15
|
-
executeTrade(): Promise<
|
|
15
|
+
executeTrade(): Promise<TradeResult>;
|
|
16
16
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ThorchainSwapper = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
5
|
class ThorchainSwapper {
|
|
6
6
|
getType() {
|
|
7
|
-
return
|
|
7
|
+
return api_1.SwapperType.Thorchain;
|
|
8
8
|
}
|
|
9
9
|
// TODO populate supported assets from midgard
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApprovalNeededInput } from '../../../api';
|
|
1
|
+
import { SupportedChainIds } from '@shapeshiftoss/types';
|
|
2
|
+
import { ApprovalNeededInput, ApprovalNeededOutput } from '../../../api';
|
|
3
3
|
import { ZrxSwapperDeps } from '../ZrxSwapper';
|
|
4
4
|
export declare function ZrxApprovalNeeded({ adapterManager, web3 }: ZrxSwapperDeps, { quote, wallet }: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
|
|
3
|
-
import {
|
|
3
|
+
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
4
4
|
import Web3 from 'web3';
|
|
5
|
-
import { ApprovalNeededInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, TradeQuote, ZrxTrade } from '../../api';
|
|
5
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetMinMaxInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperType, TradeQuote, TradeResult, ZrxTrade } from '../../api';
|
|
6
6
|
export declare type ZrxSwapperDeps = {
|
|
7
7
|
adapterManager: ChainAdapterManager;
|
|
8
8
|
web3: Web3;
|
|
@@ -17,7 +17,7 @@ export declare class ZrxSwapper implements Swapper {
|
|
|
17
17
|
getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<SupportedChainIds>>;
|
|
18
18
|
getUsdRate(input: Pick<Asset, 'symbol' | 'assetId'>): Promise<string>;
|
|
19
19
|
getMinMax(input: GetMinMaxInput): Promise<MinMaxOutput>;
|
|
20
|
-
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<
|
|
20
|
+
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<TradeResult>;
|
|
21
21
|
approvalNeeded(args: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
|
|
22
22
|
approveInfinite(args: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
|
|
23
23
|
filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZrxSwapper = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
5
|
const getZrxMinMax_1 = require("./getZrxMinMax/getZrxMinMax");
|
|
6
6
|
const getZrxTradeQuote_1 = require("./getZrxTradeQuote/getZrxTradeQuote");
|
|
7
7
|
const blacklist_1 = require("./utils/blacklist");
|
|
@@ -18,7 +18,7 @@ class ZrxSwapper {
|
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
19
19
|
async initialize() { }
|
|
20
20
|
getType() {
|
|
21
|
-
return
|
|
21
|
+
return api_1.SwapperType.Zrx;
|
|
22
22
|
}
|
|
23
23
|
async buildTrade(args) {
|
|
24
24
|
return (0, zrxBuildTrade_1.zrxBuildTrade)(this.deps, args);
|