@shapeshiftoss/swapper 5.9.0 → 5.10.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.
- package/dist/api.d.ts +1 -1
- package/dist/swappercli.js +2 -13
- package/dist/swappers/zrx/ZrxSwapper.d.ts +1 -1
- package/dist/swappers/zrx/utils/helpers/helpers.d.ts +1 -1
- package/dist/swappers/zrx/utils/helpers/helpers.js +3 -3
- package/dist/swappers/zrx/utils/test-data/assets.js +0 -20
- package/package.json +7 -7
package/dist/api.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ export interface Swapper {
|
|
|
170
170
|
/**
|
|
171
171
|
* Get the usd rate from either the assets symbol or tokenId
|
|
172
172
|
*/
|
|
173
|
-
getUsdRate(input:
|
|
173
|
+
getUsdRate(input: Asset): Promise<string>;
|
|
174
174
|
/**
|
|
175
175
|
* Execute a trade built with buildTrade by signing and broadcasting
|
|
176
176
|
*/
|
package/dist/swappercli.js
CHANGED
|
@@ -48,19 +48,8 @@ const main = async () => {
|
|
|
48
48
|
`);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
const assetService = new asset_service_1.AssetService(
|
|
52
|
-
|
|
53
|
-
const assets = assetService.byNetwork(types_1.NetworkTypes.MAINNET);
|
|
54
|
-
if (!assets) {
|
|
55
|
-
console.error('No assets found in asset service');
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const assetMap = assets.reduce((acc, val) => {
|
|
59
|
-
if (val) {
|
|
60
|
-
acc[val.symbol] = val;
|
|
61
|
-
}
|
|
62
|
-
return acc;
|
|
63
|
-
}, {});
|
|
51
|
+
const assetService = new asset_service_1.AssetService();
|
|
52
|
+
const assetMap = assetService.getAll();
|
|
64
53
|
const sellAsset = assetMap[sellSymbol];
|
|
65
54
|
const buyAsset = assetMap[buySymbol];
|
|
66
55
|
if (!sellAsset) {
|
|
@@ -15,7 +15,7 @@ export declare class ZrxSwapper implements Swapper {
|
|
|
15
15
|
getType(): SwapperType;
|
|
16
16
|
buildTrade(args: BuildTradeInput): Promise<ZrxTrade<SupportedChainIds>>;
|
|
17
17
|
getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<SupportedChainIds>>;
|
|
18
|
-
getUsdRate(input:
|
|
18
|
+
getUsdRate(input: Asset): Promise<string>;
|
|
19
19
|
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<TradeResult>;
|
|
20
20
|
approvalNeeded(args: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
|
|
21
21
|
approveInfinite(args: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
|
|
@@ -38,6 +38,6 @@ declare type GrantAllowanceArgs = {
|
|
|
38
38
|
export declare const normalizeAmount: (amount: string | number | BigNumber) => string;
|
|
39
39
|
export declare const getERC20Allowance: ({ erc20AllowanceAbi, web3, sellAssetErc20Address, ownerAddress, spenderAddress }: GetERC20AllowanceArgs) => Promise<any>;
|
|
40
40
|
export declare const getAllowanceRequired: ({ receiveAddress, allowanceContract, sellAsset, sellAmount, web3, erc20AllowanceAbi }: GetAllowanceRequiredArgs) => Promise<BigNumber>;
|
|
41
|
-
export declare const getUsdRate: (
|
|
41
|
+
export declare const getUsdRate: (asset: Asset) => Promise<string>;
|
|
42
42
|
export declare const grantAllowance: ({ quote, wallet, adapterManager, erc20Abi, web3 }: GrantAllowanceArgs) => Promise<string>;
|
|
43
43
|
export {};
|
|
@@ -59,9 +59,9 @@ const getAllowanceRequired = async ({ receiveAddress, allowanceContract, sellAss
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
exports.getAllowanceRequired = getAllowanceRequired;
|
|
62
|
-
const getUsdRate = async (
|
|
63
|
-
const {
|
|
64
|
-
const {
|
|
62
|
+
const getUsdRate = async (asset) => {
|
|
63
|
+
const { assetReference: erc20Address, assetNamespace } = (0, caip_1.fromAssetId)(asset.assetId);
|
|
64
|
+
const { symbol } = asset;
|
|
65
65
|
try {
|
|
66
66
|
const USDC_CONTRACT_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
|
|
67
67
|
if ((erc20Address === null || erc20Address === void 0 ? void 0 : erc20Address.toLowerCase()) === USDC_CONTRACT_ADDRESS)
|
|
@@ -7,19 +7,13 @@ exports.BTC = {
|
|
|
7
7
|
chainId: 'bip122:000000000019d6689c085ae165831e93',
|
|
8
8
|
name: 'bitcoin',
|
|
9
9
|
chain: types_1.ChainTypes.Bitcoin,
|
|
10
|
-
dataSource: types_1.AssetDataSource.CoinGecko,
|
|
11
10
|
network: types_1.NetworkTypes.MAINNET,
|
|
12
11
|
precision: 8,
|
|
13
|
-
slip44: 44,
|
|
14
|
-
contractType: 'erc20',
|
|
15
12
|
color: '#FFFFFF',
|
|
16
|
-
secondaryColor: '#FFFFFF',
|
|
17
13
|
icon: 'https://assets.coincap.io/assets/icons/btc@2x.png',
|
|
18
14
|
explorer: 'https://live.blockcypher.com',
|
|
19
15
|
explorerTxLink: 'https://live.blockcypher.com/btc/tx/',
|
|
20
16
|
explorerAddressLink: 'https://live.blockcypher.com/btc/address/',
|
|
21
|
-
sendSupport: false,
|
|
22
|
-
receiveSupport: false,
|
|
23
17
|
symbol: 'BTC'
|
|
24
18
|
};
|
|
25
19
|
exports.WETH = {
|
|
@@ -27,20 +21,13 @@ exports.WETH = {
|
|
|
27
21
|
chainId: 'eip155:1',
|
|
28
22
|
name: 'WETH',
|
|
29
23
|
chain: types_1.ChainTypes.Ethereum,
|
|
30
|
-
dataSource: types_1.AssetDataSource.CoinGecko,
|
|
31
24
|
network: types_1.NetworkTypes.MAINNET,
|
|
32
25
|
precision: 18,
|
|
33
|
-
tokenId: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
34
|
-
contractType: 'erc20',
|
|
35
26
|
color: '#FFFFFF',
|
|
36
|
-
secondaryColor: '#FFFFFF',
|
|
37
27
|
icon: 'https://assets.coingecko.com/coins/images/2518/thumb/weth.png?1628852295',
|
|
38
|
-
slip44: 60,
|
|
39
28
|
explorer: 'https://etherscan.io',
|
|
40
29
|
explorerTxLink: 'https://etherscan.io/tx/',
|
|
41
30
|
explorerAddressLink: 'https://etherscan.io/address/',
|
|
42
|
-
sendSupport: true,
|
|
43
|
-
receiveSupport: true,
|
|
44
31
|
symbol: 'WETH'
|
|
45
32
|
};
|
|
46
33
|
exports.FOX = {
|
|
@@ -48,19 +35,12 @@ exports.FOX = {
|
|
|
48
35
|
chainId: 'eip155:1',
|
|
49
36
|
name: 'FOX',
|
|
50
37
|
chain: types_1.ChainTypes.Ethereum,
|
|
51
|
-
dataSource: types_1.AssetDataSource.CoinGecko,
|
|
52
38
|
network: types_1.NetworkTypes.MAINNET,
|
|
53
39
|
precision: 18,
|
|
54
|
-
tokenId: '0xc770eefad204b5180df6a14ee197d99d808ee52d',
|
|
55
|
-
contractType: 'erc20',
|
|
56
40
|
color: '#FFFFFF',
|
|
57
|
-
secondaryColor: '#FFFFFF',
|
|
58
41
|
icon: 'https://assets.coincap.io/assets/icons/fox@2x.png',
|
|
59
|
-
sendSupport: true,
|
|
60
|
-
slip44: 60,
|
|
61
42
|
explorer: 'https://etherscan.io',
|
|
62
43
|
explorerTxLink: 'https://etherscan.io/tx/',
|
|
63
44
|
explorerAddressLink: 'https://etherscan.io/address/',
|
|
64
|
-
receiveSupport: true,
|
|
65
45
|
symbol: 'FOX'
|
|
66
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/swapper",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "TODO: description",
|
|
5
5
|
"repository": "https://github.com/shapeshift/lib",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"web3": "^1.6.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@shapeshiftoss/asset-service": "^4.
|
|
33
|
+
"@shapeshiftoss/asset-service": "^4.6.0",
|
|
34
34
|
"@shapeshiftoss/caip": "^5.2.1",
|
|
35
|
-
"@shapeshiftoss/chain-adapters": "^4.
|
|
35
|
+
"@shapeshiftoss/chain-adapters": "^4.7.0",
|
|
36
36
|
"@shapeshiftoss/hdwallet-core": "1.20.0",
|
|
37
|
-
"@shapeshiftoss/types": "4.
|
|
37
|
+
"@shapeshiftoss/types": "^4.4.0",
|
|
38
38
|
"@shapeshiftoss/errors": "^1.1.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@shapeshiftoss/asset-service": "^4.
|
|
41
|
+
"@shapeshiftoss/asset-service": "^4.6.0",
|
|
42
42
|
"@shapeshiftoss/caip": "^5.2.1",
|
|
43
|
-
"@shapeshiftoss/chain-adapters": "^4.
|
|
43
|
+
"@shapeshiftoss/chain-adapters": "^4.7.0",
|
|
44
44
|
"@shapeshiftoss/hdwallet-core": "^1.20.0",
|
|
45
|
-
"@shapeshiftoss/types": "4.
|
|
45
|
+
"@shapeshiftoss/types": "^4.4.0",
|
|
46
46
|
"@shapeshiftoss/errors": "^1.1.0",
|
|
47
47
|
"@types/readline-sync": "^1.4.4",
|
|
48
48
|
"readline-sync": "^1.4.10",
|