@shapeshiftoss/swapper 14.5.0 → 14.5.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 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: string;
148
+ name: SwapperName | string;
149
149
  proportion: string;
150
150
  };
151
151
  export interface MinMaxOutput {
@@ -203,7 +203,7 @@ export declare enum SwapErrorTypes {
203
203
  }
204
204
  export interface Swapper<T extends ChainId> {
205
205
  /** Human-readable swapper name */
206
- readonly name: string;
206
+ readonly name: SwapperName;
207
207
  /** perform any necessary async initialization */
208
208
  initialize?(): Promise<void>;
209
209
  /** Returns the swapper type */
@@ -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 SwapperManager_1 = require("./manager/SwapperManager");
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 SwapperManager_1.SwapperManager();
86
- const zrxSwapper = new ZrxSwapper_1.ZrxSwapper(zrxSwapperDeps);
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,8 +1,9 @@
1
+ import { SwapperName } from '../../../api';
1
2
  export declare const MAX_ALLOWANCE = "100000000000000000000000000";
2
3
  export declare const MAX_COWSWAP_TRADE = "100000000000000000000000000";
3
4
  export declare const MIN_COWSWAP_VALUE_USD = 20;
4
5
  export declare const DEFAULT_SOURCE: {
5
- name: string;
6
+ name: SwapperName;
6
7
  proportion: string;
7
8
  }[];
8
9
  export declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.COW_SWAP_ETH_MARKER_ADDRESS = exports.ORDER_STATUS_FULFILLED = exports.ERC20_TOKEN_BALANCE = exports.SIGNING_SCHEME = exports.ORDER_KIND_BUY = exports.ORDER_KIND_SELL = exports.WETH_ASSET_ID = exports.COW_SWAP_SETTLEMENT_ADDRESS = exports.COW_SWAP_VAULT_RELAYER_ADDRESS = exports.DEFAULT_APP_DATA = exports.DEFAULT_ADDRESS = exports.DEFAULT_SOURCE = exports.MIN_COWSWAP_VALUE_USD = exports.MAX_COWSWAP_TRADE = exports.MAX_ALLOWANCE = void 0;
4
4
  const constants_1 = require("@ethersproject/constants");
5
+ const api_1 = require("../../../api");
5
6
  exports.MAX_ALLOWANCE = '100000000000000000000000000';
6
7
  exports.MAX_COWSWAP_TRADE = '100000000000000000000000000';
7
8
  exports.MIN_COWSWAP_VALUE_USD = 20;
8
- exports.DEFAULT_SOURCE = [{ name: 'CowSwap', proportion: '1' }];
9
+ exports.DEFAULT_SOURCE = [{ name: api_1.SwapperName.CowSwap, proportion: '1' }];
9
10
  exports.DEFAULT_ADDRESS = constants_1.AddressZero;
10
11
  exports.DEFAULT_APP_DATA = '0x68a7b5781dfe48bd5d7aeb11261c17517f5c587da682e4fade9b6a00a59b8970';
11
12
  exports.COW_SWAP_VAULT_RELAYER_ADDRESS = '0xc92e8bdf79f0507f65a392b0ab4667716bfe0110';
@@ -116,7 +116,7 @@ class OsmosisSwapper {
116
116
  sellAmountCryptoPrecision: sellAmountCryptoBase,
117
117
  sellAsset,
118
118
  bip44Params,
119
- sources: [{ name: 'Osmosis', proportion: '100' }],
119
+ sources: [{ name: api_1.SwapperName.Osmosis, proportion: '100' }],
120
120
  };
121
121
  }
122
122
  async getTradeQuote(input) {
@@ -1,5 +1,6 @@
1
+ import { SwapperName } from '../../../api';
1
2
  export declare const DEFAULT_SOURCE: {
2
- name: string;
3
+ name: SwapperName;
3
4
  proportion: string;
4
5
  }[];
5
6
  export declare const MAX_SWAPPER_SELL = "100000000000000000000000000";
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OSMO_COSMO_CHANNEL = exports.COSMO_OSMO_CHANNEL = exports.OSMOSIS_PRECISION = exports.MAX_SWAPPER_SELL = exports.DEFAULT_SOURCE = void 0;
4
- exports.DEFAULT_SOURCE = [{ name: 'Osmosis', proportion: '1' }];
4
+ const api_1 = require("../../../api");
5
+ exports.DEFAULT_SOURCE = [{ name: api_1.SwapperName.Osmosis, proportion: '1' }];
5
6
  exports.MAX_SWAPPER_SELL = '100000000000000000000000000';
6
7
  exports.OSMOSIS_PRECISION = 6;
7
8
  exports.COSMO_OSMO_CHANNEL = 'channel-141';
@@ -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 '../../../index';
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 index_1 = require("../../../index");
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 index_1.SwapError(`Couldnt find tx ${txid}`, {
46
- code: index_1.SwapErrorTypes.RESPONSE_ERROR,
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 index_1.SwapError('failed to get balance', {
64
- code: index_1.SwapErrorTypes.RESPONSE_ERROR,
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 index_1.SwapError(`Couldnt find channel balance for ${address}`, {
91
- code: index_1.SwapErrorTypes.RESPONSE_ERROR,
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 index_1.SwapError('failed to get pool', {
112
- code: index_1.SwapErrorTypes.POOL_NOT_FOUND,
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 index_1.SwapError('could not find pool', {
124
- code: index_1.SwapErrorTypes.POOL_NOT_FOUND,
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 index_1.SwapError('failed to get latest block', {
172
- code: index_1.SwapErrorTypes.RESPONSE_ERROR,
171
+ throw new api_1.SwapError('failed to get latest block', {
172
+ code: api_1.SwapErrorTypes.RESPONSE_ERROR,
173
173
  });
174
174
  }
175
175
  })();
@@ -62,7 +62,7 @@ const getThorTradeQuote = async ({ deps, input }) => {
62
62
  maximum: constants_3.MAX_THORCHAIN_TRADE,
63
63
  sellAmountCryptoPrecision,
64
64
  buyAmountCryptoPrecision,
65
- sources: [{ name: 'thorchain', proportion: '1' }],
65
+ sources: [{ name: api_1.SwapperName.Thorchain, proportion: '1' }],
66
66
  buyAsset,
67
67
  sellAsset,
68
68
  bip44Params,
@@ -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("../../utils/isRune/isRune");
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;
@@ -1,16 +1,5 @@
1
- export declare const UNISWAP_ROUTER_ADDRESS = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
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.APPROVAL_BUY_AMOUNT = exports.AFFILIATE_ADDRESS = exports.DEFAULT_SOURCE = exports.MAX_ZRX_TRADE = exports.MAX_GAS_PRICE = exports.LIQUIDITY_GAS_LIMIT = exports.MAX_ALLOWANCE = exports.UNISWAP_WETH_FOX_POOL_ADDRESS = exports.WETH_TOKEN_CONTRACT_ADDRESS = exports.FOX_TOKEN_CONTRACT_ADDRESS = exports.ZERO_ADDRESS = exports.UNISWAP_FACTORY_ADDRESS = exports.UNISWAP_ROUTER_ADDRESS = void 0;
4
- exports.UNISWAP_ROUTER_ADDRESS = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D';
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: '0x', proportion: '1' }];
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "14.5.0",
3
+ "version": "14.5.2",
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",