@shapeshiftoss/swapper 14.5.1 → 14.5.3
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 +1 -1
- package/dist/swappercli.js +3 -4
- package/dist/swappers/osmosis/utils/helpers.d.ts +1 -1
- package/dist/swappers/osmosis/utils/helpers.js +13 -13
- package/dist/swappers/thorchain/utils/getPriceRatio/getPriceRatio.js +1 -1
- package/dist/swappers/utils/constants.d.ts +1 -1
- package/dist/swappers/utils/constants.js +1 -1
- package/dist/swappers/zrx/utils/constants.d.ts +2 -13
- package/dist/swappers/zrx/utils/constants.js +3 -11
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export declare type ApprovalNeededInput<C extends ChainId> = {
|
|
|
145
145
|
wallet: HDWallet;
|
|
146
146
|
};
|
|
147
147
|
export declare type SwapSource = {
|
|
148
|
-
name: SwapperName;
|
|
148
|
+
name: SwapperName | string;
|
|
149
149
|
proportion: string;
|
|
150
150
|
};
|
|
151
151
|
export interface MinMaxOutput {
|
package/dist/swappercli.js
CHANGED
|
@@ -12,9 +12,8 @@ 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
14
|
const adapters_1 = require("./adapters");
|
|
15
|
-
const
|
|
15
|
+
const manager_1 = require("./manager");
|
|
16
16
|
const swappers_1 = require("./swappers");
|
|
17
|
-
const ZrxSwapper_1 = require("./swappers/zrx/ZrxSwapper");
|
|
18
17
|
dotenv_1.default.config();
|
|
19
18
|
const { ETH_NODE_URL = 'http://localhost:3000', MIDGARD_URL = 'https://dev-indexer.thorchain.shapeshift.com/v2', DEVICE_ID = 'device123', MNEMONIC = 'all all all all all all all all all all all all', } = process.env;
|
|
20
19
|
const toBaseUnit = (amount, precision) => {
|
|
@@ -82,8 +81,8 @@ const main = async () => {
|
|
|
82
81
|
adapter: ethAdapter,
|
|
83
82
|
web3,
|
|
84
83
|
};
|
|
85
|
-
const swapManager = new
|
|
86
|
-
const zrxSwapper = new
|
|
84
|
+
const swapManager = new manager_1.SwapperManager();
|
|
85
|
+
const zrxSwapper = new swappers_1.ZrxSwapper(zrxSwapperDeps);
|
|
87
86
|
swapManager.addSwapper(zrxSwapper);
|
|
88
87
|
const tcDeps = {
|
|
89
88
|
midgardUrl: MIDGARD_URL,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { osmosis } from '@shapeshiftoss/chain-adapters';
|
|
2
2
|
import { HDWallet, Osmosis } from '@shapeshiftoss/hdwallet-core';
|
|
3
|
-
import { CosmosSdkSupportedChainAdapters, TradeResult } from '../../../
|
|
3
|
+
import { CosmosSdkSupportedChainAdapters, TradeResult } from '../../../api';
|
|
4
4
|
import { IbcTransferInput } from './types';
|
|
5
5
|
export interface SymbolDenomMapping {
|
|
6
6
|
OSMO: string;
|
|
@@ -8,7 +8,7 @@ const caip_1 = require("@shapeshiftoss/caip");
|
|
|
8
8
|
const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
|
-
const
|
|
11
|
+
const api_1 = require("../../../api");
|
|
12
12
|
const bignumber_1 = require("../../utils/bignumber");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
exports.symbolDenomMapping = {
|
|
@@ -42,8 +42,8 @@ const pollForComplete = async (txid, baseUrl) => {
|
|
|
42
42
|
resolve(status);
|
|
43
43
|
}
|
|
44
44
|
else if (Date.now() - startTime > timeout) {
|
|
45
|
-
reject(new
|
|
46
|
-
code:
|
|
45
|
+
reject(new api_1.SwapError(`Couldnt find tx ${txid}`, {
|
|
46
|
+
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
@@ -60,8 +60,8 @@ const getAtomChannelBalance = async (address, osmoUrl) => {
|
|
|
60
60
|
return axios_1.default.get(`${osmoUrl}/bank/balances/${address}`);
|
|
61
61
|
}
|
|
62
62
|
catch (e) {
|
|
63
|
-
throw new
|
|
64
|
-
code:
|
|
63
|
+
throw new api_1.SwapError('failed to get balance', {
|
|
64
|
+
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
})();
|
|
@@ -87,8 +87,8 @@ const pollForAtomChannelBalance = async (address, osmoUrl) => {
|
|
|
87
87
|
resolve(balance.toString());
|
|
88
88
|
}
|
|
89
89
|
else if (Date.now() - startTime > timeout) {
|
|
90
|
-
reject(new
|
|
91
|
-
code:
|
|
90
|
+
reject(new api_1.SwapError(`Couldnt find channel balance for ${address}`, {
|
|
91
|
+
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
|
92
92
|
}));
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
@@ -108,8 +108,8 @@ const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
|
108
108
|
return axios_1.default.get(poolsUrl);
|
|
109
109
|
}
|
|
110
110
|
catch (e) {
|
|
111
|
-
throw new
|
|
112
|
-
code:
|
|
111
|
+
throw new api_1.SwapError('failed to get pool', {
|
|
112
|
+
code: api_1.SwapErrorTypes.POOL_NOT_FOUND,
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
})();
|
|
@@ -120,8 +120,8 @@ const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
|
120
120
|
(token0Denom === buyAssetDenom && token1Denom === sellAssetDenom));
|
|
121
121
|
});
|
|
122
122
|
if (!foundPool)
|
|
123
|
-
throw new
|
|
124
|
-
code:
|
|
123
|
+
throw new api_1.SwapError('could not find pool', {
|
|
124
|
+
code: api_1.SwapErrorTypes.POOL_NOT_FOUND,
|
|
125
125
|
});
|
|
126
126
|
const { sellAssetIndex, buyAssetIndex } = (() => {
|
|
127
127
|
if (foundPool.pool_assets[0].token.denom === sellAssetDenom) {
|
|
@@ -168,8 +168,8 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
|
|
|
168
168
|
return axios_1.default.get(`${blockBaseUrl}/blocks/latest`);
|
|
169
169
|
}
|
|
170
170
|
catch (e) {
|
|
171
|
-
throw new
|
|
172
|
-
code:
|
|
171
|
+
throw new api_1.SwapError('failed to get latest block', {
|
|
172
|
+
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
})();
|
|
@@ -4,7 +4,7 @@ exports.getPriceRatio = void 0;
|
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
5
|
const api_1 = require("../../../../api");
|
|
6
6
|
const bignumber_1 = require("../../../utils/bignumber");
|
|
7
|
-
const isRune_1 = require("
|
|
7
|
+
const isRune_1 = require("../isRune/isRune");
|
|
8
8
|
const thorService_1 = require("../thorService");
|
|
9
9
|
const getPriceRatio = async (deps, input) => {
|
|
10
10
|
const { buyAssetId, sellAssetId } = input;
|
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ALLOWABLE_MARKET_MOVEMENT = exports.DEFAULT_SLIPPAGE = exports.APPROVAL_GAS_LIMIT = void 0;
|
|
4
4
|
exports.APPROVAL_GAS_LIMIT = '100000'; // Most approvals are around 40k, we've seen 72k in the wild, so 100000 for safety.
|
|
5
5
|
exports.DEFAULT_SLIPPAGE = '0.03'; // 3%
|
|
6
|
-
exports.ALLOWABLE_MARKET_MOVEMENT = '0.
|
|
6
|
+
exports.ALLOWABLE_MARKET_MOVEMENT = '0.01'; // 1%
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const UNISWAP_FACTORY_ADDRESS = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
|
|
3
|
-
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
4
|
-
export declare const FOX_TOKEN_CONTRACT_ADDRESS = "0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d";
|
|
5
|
-
export declare const WETH_TOKEN_CONTRACT_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
6
|
-
export declare const UNISWAP_WETH_FOX_POOL_ADDRESS = "0x470e8de2ebaef52014a47cb5e6af86884947f08c";
|
|
1
|
+
import { SwapSource } from '../../../api';
|
|
7
2
|
export declare const MAX_ALLOWANCE = "100000000000000000000000000";
|
|
8
|
-
export declare const LIQUIDITY_GAS_LIMIT = "350000";
|
|
9
|
-
export declare const MAX_GAS_PRICE = "1000000000000";
|
|
10
3
|
export declare const MAX_ZRX_TRADE = "100000000000000000000000000";
|
|
11
|
-
export declare const DEFAULT_SOURCE:
|
|
12
|
-
name: string;
|
|
13
|
-
proportion: string;
|
|
14
|
-
}[];
|
|
4
|
+
export declare const DEFAULT_SOURCE: SwapSource[];
|
|
15
5
|
export declare const AFFILIATE_ADDRESS = "0xc770eefad204b5180df6a14ee197d99d808ee52d";
|
|
16
|
-
export declare const APPROVAL_BUY_AMOUNT = "100000000000000000";
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
exports.UNISWAP_FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
|
|
6
|
-
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
7
|
-
exports.FOX_TOKEN_CONTRACT_ADDRESS = '0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d';
|
|
8
|
-
exports.WETH_TOKEN_CONTRACT_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
9
|
-
exports.UNISWAP_WETH_FOX_POOL_ADDRESS = '0x470e8de2ebaef52014a47cb5e6af86884947f08c';
|
|
3
|
+
exports.AFFILIATE_ADDRESS = exports.DEFAULT_SOURCE = exports.MAX_ZRX_TRADE = exports.MAX_ALLOWANCE = void 0;
|
|
4
|
+
const api_1 = require("../../../api");
|
|
10
5
|
exports.MAX_ALLOWANCE = '100000000000000000000000000';
|
|
11
|
-
exports.LIQUIDITY_GAS_LIMIT = '350000'; // Most Liquidity txs are around 150000
|
|
12
|
-
exports.MAX_GAS_PRICE = '1000000000000'; // 1000 GWei
|
|
13
6
|
exports.MAX_ZRX_TRADE = '100000000000000000000000000';
|
|
14
|
-
exports.DEFAULT_SOURCE = [{ name:
|
|
7
|
+
exports.DEFAULT_SOURCE = [{ name: api_1.SwapperName.Zrx, proportion: '1' }];
|
|
15
8
|
exports.AFFILIATE_ADDRESS = '0xc770eefad204b5180df6a14ee197d99d808ee52d';
|
|
16
|
-
exports.APPROVAL_BUY_AMOUNT = '100000000000000000'; // A valid buy amount - 0.1 ETH
|
package/package.json
CHANGED