@shapeshiftoss/swapper 4.0.4 → 4.1.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
@@ -1,9 +1,20 @@
1
1
  import { AssetId } from '@shapeshiftoss/caip';
2
2
  import { HDWallet } from '@shapeshiftoss/hdwallet-core';
3
- import { ApprovalNeededOutput, Asset, chainAdapters, ChainTypes, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SwapperType } from '@shapeshiftoss/types';
3
+ import { ApprovalNeededOutput, Asset, ChainSpecific, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SupportedChainIds, SwapperType } from '@shapeshiftoss/types';
4
4
  export declare type SupportedAssetInput = {
5
5
  assetIds: AssetId[];
6
6
  };
7
+ declare type ChainSpecificQuoteFeeData<T1> = ChainSpecific<T1, {
8
+ 'eip155:1': {
9
+ estimatedGas?: string;
10
+ gasPrice?: string;
11
+ approvalFee?: string;
12
+ totalFee?: string;
13
+ };
14
+ }>;
15
+ export declare type QuoteFeeData<T1 extends SupportedChainIds> = {
16
+ fee: string;
17
+ } & ChainSpecificQuoteFeeData<T1>;
7
18
  export declare type ByPairInput = {
8
19
  sellAssetId: AssetId;
9
20
  buyAssetId: AssetId;
@@ -28,12 +39,12 @@ export declare type BuildTradeInput = CommonTradeInput & {
28
39
  slippage?: string;
29
40
  wallet: HDWallet;
30
41
  };
31
- interface TradeBase<C extends ChainTypes> {
42
+ interface TradeBase<C extends SupportedChainIds> {
32
43
  success: boolean;
33
44
  statusReason: string;
34
45
  buyAmount: string;
35
46
  sellAmount: string;
36
- feeData: chainAdapters.QuoteFeeData<C>;
47
+ feeData: QuoteFeeData<C>;
37
48
  rate: string;
38
49
  allowanceContract: string;
39
50
  sources: Array<SwapSource>;
@@ -41,16 +52,16 @@ interface TradeBase<C extends ChainTypes> {
41
52
  sellAsset: Asset;
42
53
  sellAssetAccountId: string;
43
54
  }
44
- export interface TradeQuote<C extends ChainTypes> extends TradeBase<C> {
55
+ export interface TradeQuote<C extends SupportedChainIds> extends TradeBase<C> {
45
56
  minimum: string;
46
57
  maximum: string;
47
58
  }
48
- export interface Trade<C extends ChainTypes> extends TradeBase<C> {
59
+ export interface Trade<C extends SupportedChainIds> extends TradeBase<C> {
49
60
  txData: string;
50
61
  depositAddress: string;
51
62
  receiveAddress: string;
52
63
  }
53
- export declare type ExecuteTradeInput<C extends ChainTypes> = {
64
+ export declare type ExecuteTradeInput<C extends SupportedChainIds> = {
54
65
  trade: Trade<C>;
55
66
  wallet: HDWallet;
56
67
  };
@@ -61,11 +72,11 @@ export declare type SwapSource = {
61
72
  name: string;
62
73
  proportion: string;
63
74
  };
64
- export declare type ApproveInfiniteInput<C extends ChainTypes> = {
75
+ export declare type ApproveInfiniteInput<C extends SupportedChainIds> = {
65
76
  quote: TradeQuote<C>;
66
77
  wallet: HDWallet;
67
78
  };
68
- export declare type ApprovalNeededInput<C extends ChainTypes> = {
79
+ export declare type ApprovalNeededInput<C extends SupportedChainIds> = {
69
80
  quote: TradeQuote<C>;
70
81
  wallet: HDWallet;
71
82
  };
@@ -77,11 +88,11 @@ export interface Swapper {
77
88
  /**
78
89
  * Get builds a trade with definitive rate & txData that can be executed with executeTrade
79
90
  **/
80
- buildTrade(args: BuildTradeInput): Promise<Trade<ChainTypes>>;
91
+ buildTrade(args: BuildTradeInput): Promise<Trade<SupportedChainIds>>;
81
92
  /**
82
93
  * Get a trade quote
83
94
  */
84
- getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<ChainTypes>>;
95
+ getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<SupportedChainIds>>;
85
96
  /**
86
97
  * Get the usd rate from either the assets symbol or tokenId
87
98
  */
@@ -93,15 +104,15 @@ export interface Swapper {
93
104
  /**
94
105
  * Execute a trade built with buildTrade by signing and broadcasting
95
106
  */
96
- executeTrade(args: ExecuteTradeInput<ChainTypes>): Promise<ExecQuoteOutput>;
107
+ executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<ExecQuoteOutput>;
97
108
  /**
98
109
  * Get a boolean if a quote needs approval
99
110
  */
100
- approvalNeeded(args: ApprovalNeededInput<ChainTypes>): Promise<ApprovalNeededOutput>;
111
+ approvalNeeded(args: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
101
112
  /**
102
113
  * Get the txid of an approve infinite transaction
103
114
  */
104
- approveInfinite(args: ApproveInfiniteInput<ChainTypes>): Promise<string>;
115
+ approveInfinite(args: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
105
116
  /**
106
117
  * Get supported buyAssetId's by sellAssetId
107
118
  */
@@ -1,5 +1,5 @@
1
1
  import { AssetId } from '@shapeshiftoss/caip';
2
- import { ApprovalNeededOutput, Asset, ChainTypes, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SwapperType } from '@shapeshiftoss/types';
2
+ import { ApprovalNeededOutput, Asset, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SupportedChainIds, SwapperType } from '@shapeshiftoss/types';
3
3
  import { BuyAssetBySellIdInput, Swapper, Trade, TradeQuote } from '../../api';
4
4
  /**
5
5
  * Playground for testing different scenarios of multiple swappers in the manager.
@@ -15,7 +15,7 @@ export declare class TestSwapper implements Swapper {
15
15
  approveInfinite(): Promise<string>;
16
16
  filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
17
17
  filterAssetIdsBySellable(): AssetId[];
18
- buildTrade(): Promise<Trade<ChainTypes>>;
19
- getTradeQuote(): Promise<TradeQuote<ChainTypes>>;
18
+ buildTrade(): Promise<Trade<SupportedChainIds>>;
19
+ getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
20
20
  executeTrade(): Promise<ExecQuoteOutput>;
21
21
  }
@@ -1,5 +1,5 @@
1
1
  import { AssetId } from '@shapeshiftoss/caip';
2
- import { ApprovalNeededOutput, Asset, ChainTypes, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SwapperType } from '@shapeshiftoss/types';
2
+ import { ApprovalNeededOutput, Asset, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SupportedChainIds, SwapperType } from '@shapeshiftoss/types';
3
3
  import { Swapper, Trade, TradeQuote } from '../../api';
4
4
  export declare class ThorchainSwapper implements Swapper {
5
5
  getType(): SwapperType;
@@ -9,7 +9,7 @@ export declare class ThorchainSwapper implements Swapper {
9
9
  approveInfinite(): Promise<string>;
10
10
  filterBuyAssetsBySellAssetId(): AssetId[];
11
11
  filterAssetIdsBySellable(): AssetId[];
12
- buildTrade(): Promise<Trade<ChainTypes>>;
13
- getTradeQuote(): Promise<TradeQuote<ChainTypes>>;
12
+ buildTrade(): Promise<Trade<SupportedChainIds>>;
13
+ getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
14
14
  executeTrade(): Promise<ExecQuoteOutput>;
15
15
  }
@@ -1,4 +1,4 @@
1
- import { ApprovalNeededOutput, ChainTypes } from '@shapeshiftoss/types';
1
+ import { ApprovalNeededOutput, SupportedChainIds } from '@shapeshiftoss/types';
2
2
  import { ApprovalNeededInput } from '../../../api';
3
3
  import { ZrxSwapperDeps } from '../ZrxSwapper';
4
- export declare function ZrxApprovalNeeded({ adapterManager, web3 }: ZrxSwapperDeps, { quote, wallet }: ApprovalNeededInput<ChainTypes>): Promise<ApprovalNeededOutput>;
4
+ export declare function ZrxApprovalNeeded({ adapterManager, web3 }: ZrxSwapperDeps, { quote, wallet }: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZrxApprovalNeeded = void 0;
4
- const types_1 = require("@shapeshiftoss/types");
5
4
  const api_1 = require("../../../api");
6
5
  const erc20Allowance_abi_1 = require("../utils/abi/erc20Allowance-abi");
7
6
  const bignumber_1 = require("../utils/bignumber");
@@ -10,14 +9,14 @@ const helpers_1 = require("../utils/helpers/helpers");
10
9
  async function ZrxApprovalNeeded({ adapterManager, web3 }, { quote, wallet }) {
11
10
  var _a, _b;
12
11
  const { sellAsset } = quote;
12
+ if (sellAsset.chainId !== 'eip155:1') {
13
+ throw new api_1.SwapError('ZrxSwapper:ZrxApprovalNeeded only Ethereum chain type is supported');
14
+ }
13
15
  if (sellAsset.symbol === 'ETH') {
14
16
  return { approvalNeeded: false };
15
17
  }
16
- if (sellAsset.chain !== types_1.ChainTypes.Ethereum) {
17
- throw new api_1.SwapError('ZrxSwapper:ZrxApprovalNeeded only Ethereum chain type is supported');
18
- }
19
18
  const accountNumber = quote.sellAssetAccountId ? Number(quote.sellAssetAccountId) : 0;
20
- const adapter = adapterManager.byChain(sellAsset.chain);
19
+ const adapter = await adapterManager.byChainId(sellAsset.chainId);
21
20
  const bip44Params = adapter.buildBIP44Params({ accountNumber });
22
21
  const receiveAddress = await adapter.getAddress({ wallet, bip44Params });
23
22
  if (!quote.sellAsset.tokenId || !quote.allowanceContract) {
@@ -1,4 +1,4 @@
1
- import { ChainTypes } from '@shapeshiftoss/types';
1
+ import { SupportedChainIds } from '@shapeshiftoss/types';
2
2
  import { ApproveInfiniteInput } from '../../../api';
3
3
  import { ZrxSwapperDeps } from '../ZrxSwapper';
4
- export declare function ZrxApproveInfinite({ adapterManager, web3 }: ZrxSwapperDeps, { quote, wallet }: ApproveInfiniteInput<ChainTypes>): Promise<string>;
4
+ export declare function ZrxApproveInfinite({ adapterManager, web3 }: ZrxSwapperDeps, { quote, wallet }: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZrxApproveInfinite = void 0;
4
- const types_1 = require("@shapeshiftoss/types");
5
4
  const erc20_abi_1 = require("../utils/abi/erc20-abi");
6
5
  const constants_1 = require("../utils/constants");
7
6
  const helpers_1 = require("../utils/helpers/helpers");
8
7
  async function ZrxApproveInfinite({ adapterManager, web3 }, { quote, wallet }) {
9
- const adapter = adapterManager.byChain(types_1.ChainTypes.Ethereum);
10
8
  const allowanceGrantRequired = await (0, helpers_1.grantAllowance)({
11
9
  quote: {
12
10
  ...quote,
@@ -14,7 +12,7 @@ async function ZrxApproveInfinite({ adapterManager, web3 }, { quote, wallet }) {
14
12
  sellAmount: constants_1.MAX_ALLOWANCE
15
13
  },
16
14
  wallet,
17
- adapter,
15
+ adapterManager,
18
16
  erc20Abi: erc20_abi_1.erc20Abi,
19
17
  web3
20
18
  });
@@ -1,6 +1,6 @@
1
1
  import { AssetId } from '@shapeshiftoss/caip';
2
2
  import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
3
- import { ApprovalNeededOutput, Asset, ChainTypes, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SwapperType } from '@shapeshiftoss/types';
3
+ import { ApprovalNeededOutput, Asset, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SupportedChainIds, SwapperType } from '@shapeshiftoss/types';
4
4
  import Web3 from 'web3';
5
5
  import { ApprovalNeededInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, Trade, TradeQuote } from '../../api';
6
6
  export declare type ZrxSwapperDeps = {
@@ -15,13 +15,13 @@ export declare class ZrxSwapper implements Swapper {
15
15
  deps: ZrxSwapperDeps;
16
16
  constructor(deps: ZrxSwapperDeps);
17
17
  getType(): SwapperType;
18
- buildTrade(args: BuildTradeInput): Promise<Trade<ChainTypes>>;
19
- getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<ChainTypes>>;
18
+ buildTrade(args: BuildTradeInput): Promise<Trade<SupportedChainIds>>;
19
+ getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<SupportedChainIds>>;
20
20
  getUsdRate(input: Pick<Asset, 'symbol' | 'tokenId'>): Promise<string>;
21
21
  getMinMax(input: GetMinMaxInput): Promise<MinMaxOutput>;
22
- executeTrade(args: ExecuteTradeInput<ChainTypes>): Promise<ExecQuoteOutput>;
23
- approvalNeeded(args: ApprovalNeededInput<ChainTypes>): Promise<ApprovalNeededOutput>;
24
- approveInfinite(args: ApproveInfiniteInput<ChainTypes>): Promise<string>;
22
+ executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<ExecQuoteOutput>;
23
+ approvalNeeded(args: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
24
+ approveInfinite(args: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
25
25
  filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
26
26
  filterAssetIdsBySellable(assetIds?: AssetId[]): AssetId[];
27
27
  }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getZrxMinMax = void 0;
4
- const types_1 = require("@shapeshiftoss/types");
5
4
  const bignumber_1 = require("../utils/bignumber");
6
5
  const constants_1 = require("../utils/constants");
7
6
  const helpers_1 = require("../utils/helpers/helpers");
8
7
  const ZrxSwapper_1 = require("../ZrxSwapper");
9
8
  const getZrxMinMax = async (sellAsset, buyAsset) => {
10
- if (sellAsset.chain !== types_1.ChainTypes.Ethereum || buyAsset.chain !== types_1.ChainTypes.Ethereum) {
9
+ if (sellAsset.chainId !== 'eip155:1' || buyAsset.chainId !== 'eip155:1') {
11
10
  throw new ZrxSwapper_1.ZrxError('getZrxMinMax - must be eth assets');
12
11
  }
13
12
  const usdRate = await (0, helpers_1.getUsdRate)({
@@ -1,3 +1,2 @@
1
- import { ChainTypes } from '@shapeshiftoss/types';
2
1
  import { GetTradeQuoteInput, TradeQuote } from '../../../api';
3
- export declare function getZrxTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<ChainTypes.Ethereum>>;
2
+ export declare function getZrxTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<'eip155:1'>>;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getZrxTradeQuote = void 0;
4
- const types_1 = require("@shapeshiftoss/types");
5
4
  const getZrxMinMax_1 = require("../getZrxMinMax/getZrxMinMax");
6
5
  const bignumber_1 = require("../utils/bignumber");
7
6
  const constants_1 = require("../utils/constants");
@@ -17,15 +16,15 @@ async function getZrxTradeQuote(input) {
17
16
  if (!sellAsset) {
18
17
  throw new ZrxSwapper_1.ZrxError('getQuote - Missing sellAsset');
19
18
  }
20
- if (buyAsset.chain !== types_1.ChainTypes.Ethereum || sellAsset.chain !== types_1.ChainTypes.Ethereum) {
19
+ if (buyAsset.chainId !== 'eip155:1' || sellAsset.chainId !== 'eip155:1') {
21
20
  throw new ZrxSwapper_1.ZrxError('getQuote - Both assets need to be on the Ethereum chain to use Zrx');
22
21
  }
23
22
  const useSellAmount = !!sellAmount;
24
23
  const buyToken = buyAsset.tokenId || buyAsset.symbol;
25
24
  const sellToken = sellAsset.tokenId || sellAsset.symbol;
26
- const { minimum, maximum } = await (0, getZrxMinMax_1.getZrxMinMax)(buyAsset, sellAsset);
25
+ const { minimum, maximum } = await (0, getZrxMinMax_1.getZrxMinMax)(sellAsset, buyAsset);
27
26
  const minQuoteSellAmount = (0, bignumber_1.bnOrZero)(minimum).times((0, bignumber_1.bn)(10).exponentiatedBy(sellAsset.precision));
28
- const normalizedSellAmount = (0, helpers_1.normalizeAmount)((0, bignumber_1.bnOrZero)(minimum).lt(minQuoteSellAmount) ? minQuoteSellAmount.toString() : sellAmount);
27
+ const normalizedSellAmount = (0, helpers_1.normalizeAmount)((0, bignumber_1.bnOrZero)(sellAmount).eq(0) ? minQuoteSellAmount.toString() : sellAmount);
29
28
  try {
30
29
  /**
31
30
  * /swap/v1/price
@@ -1,6 +1,6 @@
1
- import { ChainAdapter } from '@shapeshiftoss/chain-adapters';
1
+ import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
2
2
  import { HDWallet } from '@shapeshiftoss/hdwallet-core';
3
- import { Asset, ChainTypes } from '@shapeshiftoss/types';
3
+ import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
4
4
  import BigNumber from 'bignumber.js';
5
5
  import Web3 from 'web3';
6
6
  import { AbiItem } from 'web3-utils';
@@ -21,9 +21,9 @@ export declare type GetERC20AllowanceArgs = {
21
21
  spenderAddress: string;
22
22
  };
23
23
  declare type GrantAllowanceArgs = {
24
- quote: TradeQuote<ChainTypes>;
24
+ quote: TradeQuote<SupportedChainIds>;
25
25
  wallet: HDWallet;
26
- adapter: ChainAdapter<ChainTypes.Ethereum>;
26
+ adapterManager: ChainAdapterManager;
27
27
  erc20Abi: AbiItem[];
28
28
  web3: Web3;
29
29
  };
@@ -39,5 +39,5 @@ export declare const normalizeAmount: (amount: string | undefined) => string | u
39
39
  export declare const getERC20Allowance: ({ erc20AllowanceAbi, web3, tokenId, ownerAddress, spenderAddress }: GetERC20AllowanceArgs) => Promise<any>;
40
40
  export declare const getAllowanceRequired: ({ receiveAddress, allowanceContract, sellAsset, sellAmount, web3, erc20AllowanceAbi }: GetAllowanceRequiredArgs) => Promise<BigNumber>;
41
41
  export declare const getUsdRate: (input: Pick<Asset, 'symbol' | 'tokenId'>) => Promise<string>;
42
- export declare const grantAllowance: ({ quote, wallet, adapter, erc20Abi, web3 }: GrantAllowanceArgs) => Promise<string>;
42
+ export declare const grantAllowance: ({ quote, wallet, adapterManager, erc20Abi, web3 }: GrantAllowanceArgs) => Promise<string>;
43
43
  export {};
@@ -69,11 +69,12 @@ const getUsdRate = async (input) => {
69
69
  return (0, bignumber_1.bn)(1).dividedBy(price).toString();
70
70
  };
71
71
  exports.getUsdRate = getUsdRate;
72
- const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
72
+ const grantAllowance = async ({ quote, wallet, adapterManager, erc20Abi, web3 }) => {
73
73
  var _a, _b, _c, _d, _e;
74
74
  if (!quote.sellAsset.tokenId) {
75
75
  throw new Error('sellAsset.tokenId is required');
76
76
  }
77
+ const adapter = await adapterManager.byChainId('eip155:1');
77
78
  const erc20Contract = new web3.eth.Contract(erc20Abi, quote.sellAsset.tokenId);
78
79
  const approveTx = erc20Contract.methods
79
80
  .approve(quote.allowanceContract, quote.sellAmount)
@@ -1,27 +1,9 @@
1
1
  import { Asset } from '@shapeshiftoss/types';
2
+ import { TradeQuote } from '../../../../api';
2
3
  import { ZrxQuoteResponse } from '../../types';
3
4
  export declare const setupQuote: () => {
4
- quoteInput: {
5
- sellAsset: Asset;
6
- buyAsset: Asset;
7
- success: boolean;
8
- sellAmount: string;
9
- allowanceContract: string;
10
- allowanceTarget: string;
11
- receiveAddress: string;
12
- sellAssetAccountId: string;
13
- buyAssetAccountId: string;
14
- sendMax: boolean;
15
- minimum: string;
16
- maximum: string;
17
- statusReason: string;
18
- buyAmount: string;
19
- feeData: {
20
- fee: string;
21
- };
22
- rate: string;
23
- sources: never[];
24
- };
5
+ quoteInput: import("../../../../api").CommonTradeInput;
6
+ tradeQuote: TradeQuote<"eip155:1" | "bip122:000000000019d6689c085ae165831e93" | "cosmos:cosmoshub-4" | "cosmos:osmosis-1">;
25
7
  buyAsset: Asset;
26
8
  sellAsset: Asset;
27
9
  };
@@ -5,26 +5,29 @@ const assets_1 = require("./assets");
5
5
  const setupQuote = () => {
6
6
  const sellAsset = { ...assets_1.FOX };
7
7
  const buyAsset = { ...assets_1.WETH };
8
- const quoteInput = {
9
- sellAsset,
10
- buyAsset,
8
+ const tradeQuote = {
11
9
  success: true,
10
+ statusReason: '',
11
+ buyAmount: '',
12
12
  sellAmount: '1000000000000000000',
13
+ sellAsset,
14
+ buyAsset,
13
15
  allowanceContract: 'allowanceContractAddress',
14
- allowanceTarget: 'allowanceTargetAddress',
15
- receiveAddress: 'receiveAddress',
16
16
  sellAssetAccountId: '0',
17
- buyAssetAccountId: '0',
18
- sendMax: false,
19
17
  minimum: '0',
20
18
  maximum: '999999999999',
21
- statusReason: '',
22
- buyAmount: '',
23
19
  feeData: { fee: '0' },
24
20
  rate: '1',
25
21
  sources: []
26
22
  };
27
- return { quoteInput, buyAsset, sellAsset };
23
+ const quoteInput = {
24
+ sellAmount: '1000000000000000000',
25
+ sellAsset,
26
+ buyAsset,
27
+ sellAssetAccountId: '0',
28
+ sendMax: false
29
+ };
30
+ return { quoteInput, tradeQuote, buyAsset, sellAsset };
28
31
  };
29
32
  exports.setupQuote = setupQuote;
30
33
  const setupZrxTradeQuoteResponse = () => {
@@ -11,11 +11,6 @@ export declare const chainAdapterMockFuncs: {
11
11
  }>, []>;
12
12
  signTransaction: jest.Mock<Promise<string>, []>;
13
13
  broadcastTransaction: jest.Mock<Promise<string>, []>;
14
- getInfo: jest.Mock<Promise<{
15
- data: {
16
- network: string;
17
- };
18
- }>, []>;
19
14
  getAddress: jest.Mock<Promise<string>, []>;
20
15
  getAccount: jest.Mock<Promise<{
21
16
  chainSpecific: {
@@ -13,7 +13,6 @@ exports.chainAdapterMockFuncs = {
13
13
  buildSendTransaction: jest.fn(() => Promise.resolve({ txToSign: {} })),
14
14
  signTransaction: jest.fn(() => Promise.resolve('signedTx')),
15
15
  broadcastTransaction: jest.fn(() => Promise.resolve('broadcastedTx')),
16
- getInfo: jest.fn(() => Promise.resolve({ data: { network: 'mainnet' } })),
17
16
  getAddress: jest.fn(() => Promise.resolve('address')),
18
17
  getAccount: jest.fn(() => Promise.resolve({
19
18
  chainSpecific: { tokens: [{ assetId: 'eip155:1/erc20:contractAddress', balance: '1000000' }] }
@@ -24,7 +23,8 @@ exports.chainAdapterMockFuncs = {
24
23
  };
25
24
  // @ts-ignore
26
25
  chain_adapters_1.ChainAdapterManager.mockImplementation(() => ({
27
- byChain: jest.fn(() => exports.chainAdapterMockFuncs)
26
+ byChain: jest.fn(() => exports.chainAdapterMockFuncs),
27
+ byChainId: jest.fn(() => exports.chainAdapterMockFuncs)
28
28
  }));
29
29
  const setupZrxDeps = () => {
30
30
  const unchainedUrls = {
@@ -1,4 +1,4 @@
1
- import { ChainTypes } from '@shapeshiftoss/types';
1
+ import { SupportedChainIds } from '@shapeshiftoss/types';
2
2
  import { BuildTradeInput, Trade } from '../../..';
3
3
  import { ZrxSwapperDeps } from '../ZrxSwapper';
4
- export declare function zrxBuildTrade({ adapterManager, web3 }: ZrxSwapperDeps, input: BuildTradeInput): Promise<Trade<ChainTypes>>;
4
+ export declare function zrxBuildTrade({ adapterManager, web3 }: ZrxSwapperDeps, input: BuildTradeInput): Promise<Trade<SupportedChainIds>>;
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.zrxBuildTrade = void 0;
27
- const types_1 = require("@shapeshiftoss/types");
28
27
  const rax = __importStar(require("retry-axios"));
29
28
  const __1 = require("../../..");
30
29
  const erc20Allowance_abi_1 = require("../utils/abi/erc20Allowance-abi");
@@ -47,8 +46,8 @@ async function zrxBuildTrade({ adapterManager, web3 }, input) {
47
46
  if (!sellToken) {
48
47
  throw new __1.SwapError('ZrxSwapper:ZrxBuildTrade One of sellAssetContract or sellAssetSymbol or sellAssetNetwork are required');
49
48
  }
50
- if (buyAsset.chain !== types_1.ChainTypes.Ethereum) {
51
- throw new __1.SwapError(`ZrxSwapper:ZrxBuildTrade buyAsset must be on chain [${types_1.ChainTypes.Ethereum}]`);
49
+ if (buyAsset.chainId !== 'eip155:1') {
50
+ throw new __1.SwapError('ZrxSwapper:ZrxBuildTrade buyAsset must be on chainId eip155:1');
52
51
  }
53
52
  const adapter = adapterManager.byChain(buyAsset.chain);
54
53
  const bip44Params = adapter.buildBIP44Params({ accountNumber: Number(buyAssetAccountId) });
@@ -1,4 +1,3 @@
1
- import { ChainTypes } from '@shapeshiftoss/types';
2
1
  import { ExecuteTradeInput, TradeResult } from '../../../api';
3
2
  import { ZrxSwapperDeps } from '../ZrxSwapper';
4
- export declare function zrxExecuteTrade({ adapterManager }: ZrxSwapperDeps, { trade, wallet }: ExecuteTradeInput<ChainTypes.Ethereum>): Promise<TradeResult>;
3
+ export declare function zrxExecuteTrade({ adapterManager }: ZrxSwapperDeps, { trade, wallet }: ExecuteTradeInput<'eip155:1'>): Promise<TradeResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "4.0.4",
3
+ "version": "4.1.2",
4
4
  "description": "TODO: description",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",