@shapeshiftoss/swapper 8.6.0 → 8.6.1

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.
@@ -12,7 +12,6 @@ export declare type CowSwapperDeps = {
12
12
  apiUrl: string;
13
13
  adapter: ethereum.ChainAdapter;
14
14
  web3: Web3;
15
- feeAsset: Asset;
16
15
  };
17
16
  export declare class CowSwapper implements Swapper<KnownChainIds.EthereumMainnet> {
18
17
  readonly name = "CowSwap";
@@ -9,6 +9,7 @@ export declare const DEFAULT_ADDRESS = "0x00000000000000000000000000000000000000
9
9
  export declare const DEFAULT_APP_DATA = "0x0000000000000000000000000000000000000000000000000000000000000000";
10
10
  export declare const COW_SWAP_VAULT_RELAYER_ADDRESS = "0xc92e8bdf79f0507f65a392b0ab4667716bfe0110";
11
11
  export declare const COW_SWAP_SETTLEMENT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41";
12
+ export declare const WETH_ASSET_ID = "eip155:1/erc20:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
12
13
  export declare const ORDER_KIND_SELL = "sell";
13
14
  export declare const SIGNING_SCHEME = "ethsign";
14
15
  export declare const ERC20_TOKEN_BALANCE = "erc20";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ORDER_STATUS_FULFILLED = exports.ERC20_TOKEN_BALANCE = exports.SIGNING_SCHEME = exports.ORDER_KIND_SELL = 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;
3
+ exports.ORDER_STATUS_FULFILLED = exports.ERC20_TOKEN_BALANCE = exports.SIGNING_SCHEME = 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
5
  exports.MAX_ALLOWANCE = '100000000000000000000000000';
6
6
  exports.MAX_COWSWAP_TRADE = '100000000000000000000000000';
@@ -10,6 +10,7 @@ exports.DEFAULT_ADDRESS = constants_1.AddressZero;
10
10
  exports.DEFAULT_APP_DATA = constants_1.HashZero;
11
11
  exports.COW_SWAP_VAULT_RELAYER_ADDRESS = '0xc92e8bdf79f0507f65a392b0ab4667716bfe0110';
12
12
  exports.COW_SWAP_SETTLEMENT_ADDRESS = '0x9008D19f58AAbD9eD0D60971565AA8510560ab41';
13
+ exports.WETH_ASSET_ID = 'eip155:1/erc20:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
13
14
  exports.ORDER_KIND_SELL = 'sell';
14
15
  exports.SIGNING_SCHEME = 'ethsign';
15
16
  exports.ERC20_TOKEN_BALANCE = 'erc20';
@@ -34,7 +34,7 @@ export declare type CowSwapQuoteApiInput = {
34
34
  sellToken: string;
35
35
  validTo: number;
36
36
  };
37
- export declare const getUsdRate: ({ apiUrl, feeAsset }: CowSwapperDeps, input: Asset) => Promise<string>;
37
+ export declare const getUsdRate: ({ apiUrl }: CowSwapperDeps, input: Asset) => Promise<string>;
38
38
  export declare const getNowPlusThirtyMinutesTimestamp: () => number;
39
39
  export declare const hashTypedData: (domain: TypedDataDomain, types: TypedDataTypes, data: Record<string, unknown>) => string;
40
40
  /**
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.domain = exports.hashOrder = exports.hashTypedData = exports.getNowPlusThirtyMinutesTimestamp = exports.getUsdRate = exports.ORDER_TYPE_FIELDS = void 0;
4
+ const asset_service_1 = require("@shapeshiftoss/asset-service");
4
5
  const caip_1 = require("@shapeshiftoss/caip");
5
6
  const ethers_1 = require("ethers");
6
7
  const api_1 = require("../../../../api");
7
8
  const bignumber_1 = require("../../../utils/bignumber");
9
+ const constants_1 = require("../constants");
8
10
  const cowService_1 = require("../cowService");
9
11
  const USDC_CONTRACT_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
10
12
  const USDC_ASSET_PRECISION = 6;
@@ -22,9 +24,9 @@ exports.ORDER_TYPE_FIELDS = [
22
24
  { name: 'sellTokenBalance', type: 'string' },
23
25
  { name: 'buyTokenBalance', type: 'string' }
24
26
  ];
25
- const getUsdRate = async ({ apiUrl, feeAsset }, input) => {
27
+ const getUsdRate = async ({ apiUrl }, input) => {
26
28
  // Replacing ETH by WETH specifically for CowSwap in order to get an usd rate when called with ETH as feeAsset
27
- const asset = input.assetId !== caip_1.ethAssetId ? input : feeAsset;
29
+ const asset = input.assetId !== caip_1.ethAssetId ? input : new asset_service_1.AssetService().getAll()[constants_1.WETH_ASSET_ID];
28
30
  const { assetReference: erc20Address, assetNamespace } = (0, caip_1.fromAssetId)(asset.assetId);
29
31
  if (assetNamespace !== 'erc20') {
30
32
  throw new api_1.SwapError('[getUsdRate] - unsupported asset namespace', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "8.6.0",
3
+ "version": "8.6.1",
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",