@shapeshiftoss/swapper 5.1.2 → 5.1.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 CHANGED
@@ -79,9 +79,11 @@ export interface TradeQuote<C extends SupportedChainIds> extends TradeBase<C> {
79
79
  maximum: string;
80
80
  }
81
81
  export interface Trade<C extends SupportedChainIds> extends TradeBase<C> {
82
+ receiveAddress: string;
83
+ }
84
+ export interface ZrxTrade<C extends SupportedChainIds> extends Trade<C> {
82
85
  txData: string;
83
86
  depositAddress: string;
84
- receiveAddress: string;
85
87
  }
86
88
  export declare type ExecuteTradeInput<C extends SupportedChainIds> = {
87
89
  trade: Trade<C>;
@@ -2,7 +2,7 @@ import { AssetId } from '@shapeshiftoss/caip';
2
2
  import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
3
3
  import { ApprovalNeededOutput, Asset, ExecQuoteOutput, GetMinMaxInput, MinMaxOutput, SupportedChainIds, SwapperType } from '@shapeshiftoss/types';
4
4
  import Web3 from 'web3';
5
- import { ApprovalNeededInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, Trade, TradeQuote } from '../../api';
5
+ import { ApprovalNeededInput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, TradeQuote, ZrxTrade } from '../../api';
6
6
  export declare type ZrxSwapperDeps = {
7
7
  adapterManager: ChainAdapterManager;
8
8
  web3: Web3;
@@ -12,7 +12,7 @@ export declare class ZrxSwapper implements Swapper {
12
12
  deps: ZrxSwapperDeps;
13
13
  constructor(deps: ZrxSwapperDeps);
14
14
  getType(): SwapperType;
15
- buildTrade(args: BuildTradeInput): Promise<Trade<SupportedChainIds>>;
15
+ buildTrade(args: BuildTradeInput): Promise<ZrxTrade<SupportedChainIds>>;
16
16
  getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<SupportedChainIds>>;
17
17
  getUsdRate(input: Pick<Asset, 'symbol' | 'tokenId'>): Promise<string>;
18
18
  getMinMax(input: GetMinMaxInput): Promise<MinMaxOutput>;
@@ -1,4 +1,4 @@
1
1
  import { SupportedChainIds } from '@shapeshiftoss/types';
2
- import { BuildTradeInput, Trade } from '../../..';
2
+ import { BuildTradeInput, ZrxTrade } from '../../..';
3
3
  import { ZrxSwapperDeps } from '../ZrxSwapper';
4
- export declare function zrxBuildTrade({ adapterManager, web3 }: ZrxSwapperDeps, input: BuildTradeInput): Promise<Trade<SupportedChainIds>>;
4
+ export declare function zrxBuildTrade({ adapterManager, web3 }: ZrxSwapperDeps, input: BuildTradeInput): Promise<ZrxTrade<SupportedChainIds>>;
@@ -6,7 +6,8 @@ const api_1 = require("../../../api");
6
6
  const bignumber_1 = require("../utils/bignumber");
7
7
  async function zrxExecuteTrade({ adapterManager }, { trade, wallet }) {
8
8
  var _a, _b, _c, _d, _e, _f;
9
- const { sellAsset } = trade;
9
+ const zrxTrade = trade;
10
+ const { sellAsset } = zrxTrade;
10
11
  try {
11
12
  // value is 0 for erc20s
12
13
  const value = sellAsset.assetId === 'eip155:1/slip44:60' ? trade.sellAmount : '0';
@@ -17,7 +18,7 @@ async function zrxExecuteTrade({ adapterManager }, { trade, wallet }) {
17
18
  const buildTxResponse = await adapter.buildSendTransaction({
18
19
  value,
19
20
  wallet,
20
- to: trade.depositAddress,
21
+ to: zrxTrade.depositAddress,
21
22
  chainSpecific: {
22
23
  gasPrice: (0, web3_utils_1.numberToHex)(((_b = (_a = trade.feeData) === null || _a === void 0 ? void 0 : _a.chainSpecific) === null || _b === void 0 ? void 0 : _b.gasPrice) || 0),
23
24
  gasLimit: (0, web3_utils_1.numberToHex)(((_d = (_c = trade.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific) === null || _d === void 0 ? void 0 : _d.estimatedGas) || 0)
@@ -25,7 +26,7 @@ async function zrxExecuteTrade({ adapterManager }, { trade, wallet }) {
25
26
  bip44Params
26
27
  });
27
28
  const { txToSign } = buildTxResponse;
28
- const txWithQuoteData = { ...txToSign, data: (_e = trade.txData) !== null && _e !== void 0 ? _e : '' };
29
+ const txWithQuoteData = { ...txToSign, data: (_e = zrxTrade.txData) !== null && _e !== void 0 ? _e : '' };
29
30
  if (wallet.supportsOfflineSigning()) {
30
31
  const signedTx = await adapter.signTransaction({ txToSign: txWithQuoteData, wallet });
31
32
  const txid = await adapter.broadcastTransaction(signedTx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "description": "TODO: description",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",