@shapeshiftoss/swapper 8.6.1 → 9.0.0

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.
Files changed (25) hide show
  1. package/dist/api.d.ts +2 -1
  2. package/dist/swappers/cow/CowSwapper.d.ts +2 -1
  3. package/dist/swappers/cow/getCowSwapMinMax/getCowSwapMinMax.d.ts +1 -1
  4. package/dist/swappers/cow/utils/helpers/helpers.d.ts +1 -1
  5. package/dist/swappers/osmosis/OsmosisSwapper.d.ts +1 -1
  6. package/dist/swappers/test/TestSwapper.d.ts +1 -1
  7. package/dist/swappers/thorchain/ThorchainSwapper.d.ts +1 -1
  8. package/dist/swappers/thorchain/utils/bitcoin/utils/getThorTxData.d.ts +2 -1
  9. package/dist/swappers/thorchain/utils/ethereum/makeTradeTx.d.ts +2 -1
  10. package/dist/swappers/thorchain/utils/ethereum/utils/getThorTxData.d.ts +1 -1
  11. package/dist/swappers/thorchain/utils/getTradeRate/getTradeRate.d.ts +1 -1
  12. package/dist/swappers/thorchain/utils/getUsdRate/getUsdRate.d.ts +1 -1
  13. package/dist/swappers/thorchain/utils/txFeeHelpers/btcTxFees/getBtcTxFees.d.ts +2 -1
  14. package/dist/swappers/thorchain/utils/txFeeHelpers/ethTxFees/getEthTxFees.d.ts +2 -1
  15. package/dist/swappers/utils/helpers/helpers.d.ts +1 -1
  16. package/dist/swappers/utils/test-data/assets.d.ts +2 -1
  17. package/dist/swappers/utils/test-data/assets.js +21 -8
  18. package/dist/swappers/utils/test-data/setupDeps.d.ts +1 -1
  19. package/dist/swappers/utils/test-data/setupSwapQuote.d.ts +2 -1
  20. package/dist/swappers/zrx/ZrxSwapper.d.ts +1 -1
  21. package/dist/swappers/zrx/getZrxMinMax/getZrxMinMax.d.ts +1 -1
  22. package/dist/swappers/zrx/getZrxMinMax/getZrxMinMax.js +4 -1
  23. package/dist/swappers/zrx/utils/helpers/helpers.d.ts +1 -1
  24. package/dist/swappers/zrx/utils/test-data/setupZrxSwapQuote.d.ts +1 -1
  25. package/package.json +1 -1
package/dist/api.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId, ChainId } from '@shapeshiftoss/caip';
2
3
  import { avalanche, cosmos, ethereum, osmosis } from '@shapeshiftoss/chain-adapters';
3
4
  import { HDWallet } from '@shapeshiftoss/hdwallet-core';
4
- import { Asset, BIP44Params, ChainSpecific, KnownChainIds, UtxoAccountType } from '@shapeshiftoss/types';
5
+ import { BIP44Params, ChainSpecific, KnownChainIds, UtxoAccountType } from '@shapeshiftoss/types';
5
6
  export declare const SwapError: {
6
7
  new <V extends {
7
8
  cause?: unknown;
@@ -1,6 +1,7 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId } from '@shapeshiftoss/caip';
2
3
  import { ethereum } from '@shapeshiftoss/chain-adapters';
3
- import { Asset, KnownChainIds } from '@shapeshiftoss/types';
4
+ import { KnownChainIds } from '@shapeshiftoss/types';
4
5
  import Web3 from 'web3';
5
6
  import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
6
7
  import { CowTrade } from './types';
@@ -1,4 +1,4 @@
1
- import { Asset } from '@shapeshiftoss/types';
1
+ import { Asset } from '@shapeshiftoss/asset-service';
2
2
  import { MinMaxOutput } from '../../../api';
3
3
  import { CowSwapperDeps } from '../CowSwapper';
4
4
  export declare const getCowSwapMinMax: (deps: CowSwapperDeps, sellAsset: Asset, buyAsset: Asset) => Promise<MinMaxOutput>;
@@ -1,5 +1,5 @@
1
1
  import { TypedDataDomain, TypedDataField } from '@ethersproject/abstract-signer';
2
- import { Asset } from '@shapeshiftoss/types';
2
+ import { Asset } from '@shapeshiftoss/asset-service';
3
3
  import { CowSwapperDeps } from '../../CowSwapper';
4
4
  export declare const ORDER_TYPE_FIELDS: {
5
5
  name: string;
@@ -1,5 +1,5 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId, ChainId } from '@shapeshiftoss/caip';
2
- import { Asset } from '@shapeshiftoss/types';
3
3
  import { ApprovalNeededOutput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
4
4
  import { OsmoSwapperDeps } from './utils/types';
5
5
  export declare class OsmosisSwapper implements Swapper<ChainId> {
@@ -1,5 +1,5 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId, ChainId } from '@shapeshiftoss/caip';
2
- import { Asset } from '@shapeshiftoss/types';
3
3
  import { ApprovalNeededOutput, BuyAssetBySellIdInput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
4
4
  /**
5
5
  * Playground for testing different scenarios of multiple swappers in the manager.
@@ -1,5 +1,5 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId, ChainId } from '@shapeshiftoss/caip';
2
- import type { Asset } from '@shapeshiftoss/types';
3
3
  import { KnownChainIds } from '@shapeshiftoss/types';
4
4
  import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetTradeQuoteInput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
5
5
  import { ThorchainSwapperDeps } from './types';
@@ -1,5 +1,6 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { HDWallet } from '@shapeshiftoss/hdwallet-core';
2
- import { Asset, BIP44Params, UtxoAccountType } from '@shapeshiftoss/types';
3
+ import { BIP44Params, UtxoAccountType } from '@shapeshiftoss/types';
3
4
  import { ThorchainSwapperDeps } from '../../../types';
4
5
  declare type GetBtcThorTxInfoArgs = {
5
6
  deps: ThorchainSwapperDeps;
@@ -1,6 +1,7 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { ethereum } from '@shapeshiftoss/chain-adapters';
2
3
  import { ETHSignTx, HDWallet } from '@shapeshiftoss/hdwallet-core';
3
- import { Asset, BIP44Params } from '@shapeshiftoss/types';
4
+ import { BIP44Params } from '@shapeshiftoss/types';
4
5
  import { ThorchainSwapperDeps } from '../../types';
5
6
  export declare const makeTradeTx: ({ wallet, bip44Params, sellAmount, buyAsset, sellAsset, destinationAddress, adapter, maxFeePerGas, maxPriorityFeePerGas, gasPrice, slippageTolerance, deps, gasLimit }: {
6
7
  wallet: HDWallet;
@@ -1,4 +1,4 @@
1
- import { Asset } from '@shapeshiftoss/types';
1
+ import { Asset } from '@shapeshiftoss/asset-service';
2
2
  import { ThorchainSwapperDeps } from '../../../types';
3
3
  declare type GetBtcThorTxInfoArgs = {
4
4
  deps: ThorchainSwapperDeps;
@@ -1,4 +1,4 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId } from '@shapeshiftoss/caip';
2
- import { Asset } from '@shapeshiftoss/types';
3
3
  import { ThorchainSwapperDeps } from '../../types';
4
4
  export declare const getTradeRate: (sellAsset: Asset, buyAssetId: AssetId, sellAmount: string, deps: ThorchainSwapperDeps) => Promise<string>;
@@ -1,4 +1,4 @@
1
- import { Asset } from '@shapeshiftoss/types';
1
+ import { Asset } from '@shapeshiftoss/asset-service';
2
2
  import { ThorchainSwapperDeps } from '../../types';
3
3
  export declare const getUsdRate: ({ deps, input }: {
4
4
  deps: ThorchainSwapperDeps;
@@ -1,5 +1,6 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
2
- import { Asset, KnownChainIds } from '@shapeshiftoss/types';
3
+ import { KnownChainIds } from '@shapeshiftoss/types';
3
4
  import { QuoteFeeData } from '../../../../../api';
4
5
  import { ThorchainSwapperDeps } from '../../../types';
5
6
  export declare const getBtcTxFees: ({ deps, opReturnData, vault, buyAsset, sellAmount, adapterManager, pubkey }: {
@@ -1,6 +1,7 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetReference } from '@shapeshiftoss/caip';
2
3
  import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
3
- import { Asset, KnownChainIds } from '@shapeshiftoss/types';
4
+ import { KnownChainIds } from '@shapeshiftoss/types';
4
5
  import { QuoteFeeData } from '../../../../../api';
5
6
  import { ThorchainSwapperDeps } from '../../../types';
6
7
  export declare const getEthTxFees: ({ deps, data, router, buyAsset, sellAmount, adapterManager, receiveAddress, sellAssetReference }: {
@@ -1,5 +1,5 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { HDWallet } from '@shapeshiftoss/hdwallet-core';
2
- import { Asset } from '@shapeshiftoss/types';
3
3
  import BigNumber from 'bignumber.js';
4
4
  import Web3 from 'web3';
5
5
  import { AbiItem } from 'web3-utils';
@@ -1,4 +1,4 @@
1
- import { Asset } from '@shapeshiftoss/types';
1
+ import { Asset } from '@shapeshiftoss/asset-service';
2
2
  export declare const BTC: Asset;
3
3
  export declare const WETH: Asset;
4
4
  export declare const FOX: Asset;
@@ -6,3 +6,4 @@ export declare const WBTC: Asset;
6
6
  export declare const ETH: Asset;
7
7
  export declare const UNSUPPORTED: Asset;
8
8
  export declare const USDC: Asset;
9
+ export declare const AVAX: Asset;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USDC = exports.UNSUPPORTED = exports.ETH = exports.WBTC = exports.FOX = exports.WETH = exports.BTC = void 0;
3
+ exports.AVAX = exports.USDC = exports.UNSUPPORTED = exports.ETH = exports.WBTC = exports.FOX = exports.WETH = exports.BTC = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
4
5
  exports.BTC = {
5
6
  assetId: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
6
7
  chainId: 'bip122:000000000019d6689c085ae165831e93',
@@ -15,7 +16,7 @@ exports.BTC = {
15
16
  };
16
17
  exports.WETH = {
17
18
  assetId: 'eip155:1/erc20:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
18
- chainId: 'eip155:1',
19
+ chainId: caip_1.ethChainId,
19
20
  name: 'WETH',
20
21
  precision: 18,
21
22
  color: '#FFFFFF',
@@ -27,7 +28,7 @@ exports.WETH = {
27
28
  };
28
29
  exports.FOX = {
29
30
  assetId: 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d',
30
- chainId: 'eip155:1',
31
+ chainId: caip_1.ethChainId,
31
32
  name: 'FOX',
32
33
  precision: 18,
33
34
  color: '#FFFFFF',
@@ -39,7 +40,7 @@ exports.FOX = {
39
40
  };
40
41
  exports.WBTC = {
41
42
  assetId: 'eip155:1/erc20:0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
42
- chainId: 'eip155:1',
43
+ chainId: caip_1.ethChainId,
43
44
  color: '#FFFFFF',
44
45
  explorer: 'https://etherscan.io',
45
46
  explorerAddressLink: 'https://etherscan.io/address/',
@@ -50,8 +51,8 @@ exports.WBTC = {
50
51
  symbol: 'WBTC'
51
52
  };
52
53
  exports.ETH = {
53
- assetId: 'eip155:1/slip44:60',
54
- chainId: 'eip155:1',
54
+ assetId: caip_1.ethAssetId,
55
+ chainId: caip_1.ethChainId,
55
56
  symbol: 'ETH',
56
57
  name: 'Ethereum',
57
58
  precision: 18,
@@ -63,7 +64,7 @@ exports.ETH = {
63
64
  };
64
65
  exports.UNSUPPORTED = {
65
66
  assetId: 'eip155:1/slip44:420',
66
- chainId: 'eip155:1',
67
+ chainId: caip_1.ethChainId,
67
68
  symbol: 'ETH',
68
69
  name: 'Ethereum',
69
70
  precision: 18,
@@ -75,7 +76,7 @@ exports.UNSUPPORTED = {
75
76
  };
76
77
  exports.USDC = {
77
78
  assetId: 'eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
78
- chainId: 'eip155:1',
79
+ chainId: caip_1.ethChainId,
79
80
  symbol: 'USDC',
80
81
  name: 'USD Coin',
81
82
  precision: 6,
@@ -85,3 +86,15 @@ exports.USDC = {
85
86
  explorerAddressLink: 'https://etherscan.io/address/',
86
87
  explorerTxLink: 'https://etherscan.io/tx/'
87
88
  };
89
+ exports.AVAX = {
90
+ assetId: caip_1.avalancheAssetId,
91
+ chainId: caip_1.avalancheChainId,
92
+ name: 'Avalanche',
93
+ symbol: 'AVAX',
94
+ precision: 18,
95
+ color: '#FFFFFF',
96
+ icon: 'https://rawcdn.githack.com/trustwallet/assets/32e51d582a890b3dd3135fe3ee7c20c2fd699a6d/blockchains/avalanchec/info/logo.png',
97
+ explorer: 'https://snowtrace.io',
98
+ explorerAddressLink: 'https://snowtrace.io/address/',
99
+ explorerTxLink: 'https://snowtrace.io/tx/'
100
+ };
@@ -3,5 +3,5 @@ import Web3 from 'web3';
3
3
  export declare const setupDeps: () => {
4
4
  web3: Web3;
5
5
  adapter: ethereum.ChainAdapter;
6
- feeAsset: import("@shapeshiftoss/types").Asset;
6
+ feeAsset: import("@shapeshiftoss/asset-service").Asset;
7
7
  };
@@ -1,5 +1,6 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { HDWallet } from '@shapeshiftoss/hdwallet-core';
2
- import { Asset, KnownChainIds } from '@shapeshiftoss/types';
3
+ import { KnownChainIds } from '@shapeshiftoss/types';
3
4
  import { TradeQuote } from '../../../api';
4
5
  export declare const setupQuote: () => {
5
6
  quoteInput: import("../../../api").GetEvmTradeQuoteInput;
@@ -1,5 +1,5 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId, ChainId } from '@shapeshiftoss/caip';
2
- import { Asset } from '@shapeshiftoss/types';
3
3
  import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, EvmSupportedChainIds, GetEvmTradeQuoteInput, Swapper, SwapperType, TradeQuote, TradeResult, TradeTxs } from '../../api';
4
4
  import { ZrxExecuteTradeInput, ZrxSwapperDeps, ZrxTrade } from './types';
5
5
  export declare class ZrxSwapper<T extends EvmSupportedChainIds> implements Swapper<T> {
@@ -1,3 +1,3 @@
1
- import { Asset } from '@shapeshiftoss/types';
1
+ import { Asset } from '@shapeshiftoss/asset-service';
2
2
  import { MinMaxOutput } from '../../../api';
3
3
  export declare const getZrxMinMax: (sellAsset: Asset, buyAsset: Asset) => Promise<MinMaxOutput>;
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getZrxMinMax = void 0;
4
+ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
4
5
  const api_1 = require("../../../api");
5
6
  const bignumber_1 = require("../../utils/bignumber");
6
7
  const constants_1 = require("../utils/constants");
7
8
  const helpers_1 = require("../utils/helpers/helpers");
8
9
  const getZrxMinMax = async (sellAsset, buyAsset) => {
9
10
  try {
10
- if (sellAsset.chainId !== 'eip155:1' || buyAsset.chainId !== 'eip155:1') {
11
+ if (!((0, chain_adapters_1.isEvmChainId)(sellAsset.chainId) &&
12
+ (0, chain_adapters_1.isEvmChainId)(buyAsset.chainId) &&
13
+ buyAsset.chainId === sellAsset.chainId)) {
11
14
  throw new api_1.SwapError('[getZrxMinMax]', { code: api_1.SwapErrorTypes.UNSUPPORTED_PAIR });
12
15
  }
13
16
  const usdRate = await (0, helpers_1.getUsdRate)({ ...sellAsset });
@@ -1,5 +1,5 @@
1
+ import { Asset } from '@shapeshiftoss/asset-service';
1
2
  import { AssetId } from '@shapeshiftoss/caip';
2
- import { Asset } from '@shapeshiftoss/types';
3
3
  export declare const baseUrlFromChainId: (chainId: string) => string;
4
4
  export declare const usdcContractFromChainId: (chainId: string) => string;
5
5
  export declare const isNativeEvmAsset: (assetId: AssetId) => boolean;
@@ -1,4 +1,4 @@
1
- import { Asset } from '@shapeshiftoss/types';
1
+ import { Asset } from '@shapeshiftoss/asset-service';
2
2
  import { ZrxQuoteResponse } from '../../types';
3
3
  export declare const setupZrxTradeQuoteResponse: () => {
4
4
  quoteResponse: ZrxQuoteResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "8.6.1",
3
+ "version": "9.0.0",
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",