@shapeshiftoss/swapper 8.6.0 → 8.7.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.
- package/dist/swappers/cow/CowSwapper.d.ts +0 -1
- package/dist/swappers/cow/utils/constants.d.ts +1 -0
- package/dist/swappers/cow/utils/constants.js +2 -1
- package/dist/swappers/cow/utils/helpers/helpers.d.ts +1 -1
- package/dist/swappers/cow/utils/helpers/helpers.js +4 -2
- package/dist/swappers/utils/test-data/assets.d.ts +1 -0
- package/dist/swappers/utils/test-data/assets.js +21 -8
- package/dist/swappers/zrx/getZrxMinMax/getZrxMinMax.js +4 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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 :
|
|
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', {
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
54
|
-
chainId:
|
|
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:
|
|
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:
|
|
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
|
+
};
|
|
@@ -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
|
|
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 });
|
package/package.json
CHANGED