@shapeshiftoss/swapper 15.4.1 → 15.5.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 +6 -0
- package/dist/swappers/cow/CowSwapper.js +6 -1
- package/dist/swappers/osmosis/utils/helpers.js +2 -12
- package/dist/swappers/osmosis/utils/osmoService.d.ts +1 -0
- package/dist/swappers/osmosis/utils/osmoService.js +20 -0
- package/dist/swappers/thorchain/ThorchainSwapper.js +2 -0
- package/dist/swappers/zrx/ZrxSwapper.js +4 -3
- package/package.json +3 -3
package/dist/api.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ declare type ChainSpecificQuoteFeeData<T extends ChainId> = ChainSpecific<T, {
|
|
|
38
38
|
approvalFeeCryptoBaseUnit?: string;
|
|
39
39
|
totalFee?: string;
|
|
40
40
|
};
|
|
41
|
+
[KnownChainIds.OptimismMainnet]: {
|
|
42
|
+
estimatedGas?: string;
|
|
43
|
+
gasPriceCryptoBaseUnit?: string;
|
|
44
|
+
approvalFeeCryptoBaseUnit?: string;
|
|
45
|
+
totalFee?: string;
|
|
46
|
+
};
|
|
41
47
|
[KnownChainIds.BitcoinMainnet]: {
|
|
42
48
|
byteCount: string;
|
|
43
49
|
satsPerByte: string;
|
|
@@ -65,7 +65,12 @@ class CowSwapper {
|
|
|
65
65
|
!blacklist_1.COWSWAP_UNSUPPORTED_ASSETS.includes(id));
|
|
66
66
|
}
|
|
67
67
|
filterAssetIdsBySellable(assetIds) {
|
|
68
|
-
return assetIds.filter((id) =>
|
|
68
|
+
return assetIds.filter((id) => {
|
|
69
|
+
const { chainId, assetNamespace } = (0, caip_1.fromAssetId)(id);
|
|
70
|
+
return (chainId === types_1.KnownChainIds.EthereumMainnet &&
|
|
71
|
+
assetNamespace === caip_1.ASSET_NAMESPACE.erc20 &&
|
|
72
|
+
!blacklist_1.COWSWAP_UNSUPPORTED_ASSETS.includes(id));
|
|
73
|
+
});
|
|
69
74
|
}
|
|
70
75
|
async getTradeTxs(args) {
|
|
71
76
|
return (0, cowGetTradeTxs_1.cowGetTradeTxs)(this.deps, args);
|
|
@@ -9,19 +9,9 @@ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
11
|
const api_1 = require("../../../api");
|
|
12
|
-
const utils_1 = require("../../../utils");
|
|
13
12
|
const bignumber_1 = require("../../utils/bignumber");
|
|
14
13
|
const constants_1 = require("./constants");
|
|
15
|
-
|
|
16
|
-
const cache = (0, utils_1.createCache)(3000, ['/osmosis/gamm/v1beta1/pools/']);
|
|
17
|
-
const osmoPoolsService = axios_1.default.create({
|
|
18
|
-
timeout: 10000,
|
|
19
|
-
headers: {
|
|
20
|
-
Accept: 'application/json',
|
|
21
|
-
'Content-Type': 'application/json',
|
|
22
|
-
},
|
|
23
|
-
adapter: cache.adapter,
|
|
24
|
-
});
|
|
14
|
+
const osmoService_1 = require("./osmoService");
|
|
25
15
|
exports.symbolDenomMapping = {
|
|
26
16
|
OSMO: 'uosmo',
|
|
27
17
|
ATOM: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
|
@@ -116,7 +106,7 @@ const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
|
116
106
|
const poolsUrl = osmoUrl + '/osmosis/gamm/v1beta1/pools?pagination.limit=1000';
|
|
117
107
|
const poolsResponse = await (async () => {
|
|
118
108
|
try {
|
|
119
|
-
return
|
|
109
|
+
return osmoService_1.osmoService.get(poolsUrl);
|
|
120
110
|
}
|
|
121
111
|
catch (e) {
|
|
122
112
|
throw new api_1.SwapError('failed to get pool', {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const osmoService: import("axios").AxiosInstance;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.osmoService = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const utils_1 = require("../../../utils");
|
|
9
|
+
const maxAge = 3 * 1000; // 3 seconds
|
|
10
|
+
const cachedUrls = ['/osmosis/gamm/v1beta1/pools'];
|
|
11
|
+
const cache = (0, utils_1.createCache)(maxAge, cachedUrls);
|
|
12
|
+
const axiosConfig = {
|
|
13
|
+
timeout: 10000,
|
|
14
|
+
headers: {
|
|
15
|
+
Accept: 'application/json',
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
},
|
|
18
|
+
adapter: cache.adapter,
|
|
19
|
+
};
|
|
20
|
+
exports.osmoService = axios_1.default.create(axiosConfig);
|
|
@@ -37,6 +37,7 @@ class ThorchainSwapper {
|
|
|
37
37
|
[types_1.KnownChainIds.CosmosMainnet]: true,
|
|
38
38
|
[types_1.KnownChainIds.ThorchainMainnet]: true,
|
|
39
39
|
[types_1.KnownChainIds.AvalancheMainnet]: false,
|
|
40
|
+
[types_1.KnownChainIds.OptimismMainnet]: false,
|
|
40
41
|
};
|
|
41
42
|
this.buySupportedChainIds = {
|
|
42
43
|
[types_1.KnownChainIds.EthereumMainnet]: true,
|
|
@@ -47,6 +48,7 @@ class ThorchainSwapper {
|
|
|
47
48
|
[types_1.KnownChainIds.CosmosMainnet]: true,
|
|
48
49
|
[types_1.KnownChainIds.ThorchainMainnet]: true,
|
|
49
50
|
[types_1.KnownChainIds.AvalancheMainnet]: false,
|
|
51
|
+
[types_1.KnownChainIds.OptimismMainnet]: false,
|
|
50
52
|
};
|
|
51
53
|
this.supportedSellAssetIds = [caip_1.thorchainAssetId];
|
|
52
54
|
this.supportedBuyAssetIds = [caip_1.thorchainAssetId];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZrxSwapper = void 0;
|
|
4
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
4
5
|
const types_1 = require("@shapeshiftoss/types");
|
|
5
6
|
const api_1 = require("../../api");
|
|
6
7
|
const getZrxTradeQuote_1 = require("./getZrxTradeQuote/getZrxTradeQuote");
|
|
@@ -51,12 +52,12 @@ class ZrxSwapper {
|
|
|
51
52
|
}
|
|
52
53
|
filterBuyAssetsBySellAssetId(args) {
|
|
53
54
|
const { assetIds = [], sellAssetId } = args;
|
|
54
|
-
return assetIds.filter((id) => id.
|
|
55
|
-
(
|
|
55
|
+
return assetIds.filter((id) => (0, caip_1.fromAssetId)(id).chainId === this.chainId &&
|
|
56
|
+
(0, caip_1.fromAssetId)(sellAssetId).chainId === this.chainId &&
|
|
56
57
|
!blacklist_1.UNSUPPORTED_ASSETS.includes(id));
|
|
57
58
|
}
|
|
58
59
|
filterAssetIdsBySellable(assetIds = []) {
|
|
59
|
-
return assetIds.filter((id) => id.
|
|
60
|
+
return assetIds.filter((id) => (0, caip_1.fromAssetId)(id).chainId === this.chainId && !blacklist_1.UNSUPPORTED_ASSETS.includes(id));
|
|
60
61
|
}
|
|
61
62
|
async getTradeTxs(tradeResult) {
|
|
62
63
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/swapper",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.5.1",
|
|
4
4
|
"description": "An interface and implementations to trade coins via various protocols",
|
|
5
5
|
"repository": "https://github.com/shapeshift/lib",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@shapeshiftoss/caip": "^8.0.0",
|
|
36
36
|
"@shapeshiftoss/chain-adapters": "^10.5.0",
|
|
37
37
|
"@shapeshiftoss/errors": "^1.1.2",
|
|
38
|
-
"@shapeshiftoss/hdwallet-core": "^1.
|
|
38
|
+
"@shapeshiftoss/hdwallet-core": "^1.42.0",
|
|
39
39
|
"@shapeshiftoss/types": "^8.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@shapeshiftoss/caip": "^8.0.0",
|
|
44
44
|
"@shapeshiftoss/chain-adapters": "^10.5.0",
|
|
45
45
|
"@shapeshiftoss/errors": "^1.1.2",
|
|
46
|
-
"@shapeshiftoss/hdwallet-core": "^1.
|
|
46
|
+
"@shapeshiftoss/hdwallet-core": "^1.42.0",
|
|
47
47
|
"@shapeshiftoss/types": "^8.1.0",
|
|
48
48
|
"@shapeshiftoss/unchained-client": "^10.0.1",
|
|
49
49
|
"@types/readline-sync": "^1.4.4",
|