@shapeshiftoss/caip 8.15.0 → 8.16.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/CHANGELOG.md +726 -0
- package/dist/accountId/accountId.d.ts +9 -9
- package/dist/accountId/accountId.js +16 -20
- package/dist/accountId/accountId.test.js +107 -0
- package/dist/adapters/banxa/index.d.ts +6 -5
- package/dist/adapters/banxa/index.js +60 -38
- package/dist/adapters/coinbase/generate.js +4 -8
- package/dist/adapters/coinbase/generated/index.js +2 -8
- package/dist/adapters/coinbase/index.d.ts +1 -1
- package/dist/adapters/coinbase/index.js +7 -15
- package/dist/adapters/coinbase/utils.d.ts +2 -2
- package/dist/adapters/coinbase/utils.js +11 -23
- package/dist/adapters/coincap/generate.js +5 -7
- package/dist/adapters/coincap/generated/cosmos_thorchain-1/adapter.json +1 -0
- package/dist/adapters/coincap/generated/eip155_1/adapter.json +1 -1
- package/dist/adapters/coincap/generated/index.d.ts +2 -3
- package/dist/adapters/coincap/generated/index.js +8 -22
- package/dist/adapters/coincap/index.d.ts +2 -1
- package/dist/adapters/coincap/index.js +9 -38
- package/dist/adapters/coincap/index.test.js +92 -0
- package/dist/adapters/coincap/utils.d.ts +1 -1
- package/dist/adapters/coincap/utils.js +21 -32
- package/dist/adapters/coincap/utils.test.d.ts +4 -0
- package/dist/adapters/coincap/utils.test.js +163 -0
- package/dist/adapters/coingecko/generate.js +5 -7
- package/dist/adapters/coingecko/generated/cosmos_mayachain-mainnet-v1/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/cosmos_thorchain-1/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/eip155_1/adapter.json +1 -1
- package/dist/adapters/coingecko/generated/eip155_10/adapter.json +1 -1
- package/dist/adapters/coingecko/generated/eip155_100/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/eip155_137/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/eip155_42161/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/eip155_42170/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/eip155_43114/adapter.json +1 -1
- package/dist/adapters/coingecko/generated/eip155_56/adapter.json +1 -1
- package/dist/adapters/coingecko/generated/eip155_8453/adapter.json +1 -0
- package/dist/adapters/coingecko/generated/index.d.ts +9 -3
- package/dist/adapters/coingecko/generated/index.js +18 -28
- package/dist/adapters/coingecko/generated/solana_5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/adapter.json +1 -0
- package/dist/adapters/coingecko/index.d.ts +16 -14
- package/dist/adapters/coingecko/index.js +87 -73
- package/dist/adapters/coingecko/index.test.d.ts +1 -0
- package/dist/adapters/coingecko/index.test.js +274 -0
- package/dist/adapters/coingecko/utils.d.ts +4 -6
- package/dist/adapters/coingecko/utils.js +141 -59
- package/dist/adapters/coingecko/utils.test.d.ts +1 -0
- package/dist/adapters/coingecko/utils.test.js +188 -0
- package/dist/adapters/index.d.ts +0 -5
- package/dist/adapters/index.js +6 -27
- package/dist/adapters/mtpelerin/index.d.ts +1 -61
- package/dist/adapters/mtpelerin/index.js +96 -88
- package/dist/adapters/onramper/index.d.ts +2 -2
- package/dist/adapters/onramper/index.js +1483 -62
- package/dist/assetId/assetId.d.ts +14 -13
- package/dist/assetId/assetId.js +81 -57
- package/dist/assetId/assetId.test.d.ts +1 -0
- package/dist/assetId/assetId.test.js +336 -0
- package/dist/chainId/chainId.d.ts +11 -10
- package/dist/chainId/chainId.js +14 -16
- package/dist/chainId/chainId.test.d.ts +1 -0
- package/dist/chainId/chainId.test.js +88 -0
- package/dist/constants.d.ts +57 -38
- package/dist/constants.js +135 -108
- package/dist/index.js +7 -36
- package/dist/typeGuards.d.ts +5 -3
- package/dist/typeGuards.js +34 -40
- package/dist/utils.d.ts +7 -8
- package/dist/utils.js +23 -67
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +162 -0
- package/package.json +11 -30
- package/dist/adapters/coincap/generated/cosmos_osmosis-1/adapter.json +0 -1
- package/dist/adapters/coincap/generated/cosmos_thorchain-mainnet-v1/adapter.json +0 -1
- package/dist/adapters/coingecko/generated/cosmos_osmosis-1/adapter.json +0 -1
- package/dist/adapters/coingecko/generated/cosmos_thorchain-mainnet-v1/adapter.json +0 -1
- package/dist/adapters/gem/index.d.ts +0 -2
- package/dist/adapters/gem/index.js +0 -39
- package/dist/adapters/junopay/index.d.ts +0 -7
- package/dist/adapters/junopay/index.js +0 -52
- package/dist/adapters/osmosis/generate.js +0 -13
- package/dist/adapters/osmosis/generated/cosmos_osmosis-1/adapter.json +0 -1022
- package/dist/adapters/osmosis/generated/index.d.ts +0 -2
- package/dist/adapters/osmosis/generated/index.js +0 -8
- package/dist/adapters/osmosis/index.d.ts +0 -6
- package/dist/adapters/osmosis/index.js +0 -54
- package/dist/adapters/osmosis/utils.d.ts +0 -37
- package/dist/adapters/osmosis/utils.js +0 -90
- package/dist/adapters/thortrading/index.d.ts +0 -5
- package/dist/adapters/thortrading/index.js +0 -44
- package/dist/adapters/yearn/generate.js +0 -9
- package/dist/adapters/yearn/generated/eip155_1/adapter.json +0 -1
- package/dist/adapters/yearn/generated/index.d.ts +0 -2
- package/dist/adapters/yearn/generated/index.js +0 -8
- package/dist/adapters/yearn/index.d.ts +0 -2
- package/dist/adapters/yearn/index.js +0 -41
- package/dist/adapters/yearn/utils.d.ts +0 -7
- package/dist/adapters/yearn/utils.js +0 -62
- /package/dist/{adapters/osmosis/generate.d.ts → accountId/accountId.test.d.ts} +0 -0
- /package/dist/adapters/{yearn/generate.d.ts → coincap/index.test.d.ts} +0 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { AssetId } from '../../assetId/assetId';
|
|
2
|
-
import { ChainId } from '../../chainId/chainId';
|
|
1
|
+
import type { AssetId } from '../../assetId/assetId';
|
|
2
|
+
import type { ChainId } from '../../chainId/chainId';
|
|
3
|
+
export { fetchData as fetchCoingeckoData, parseData as parseCoingeckoData } from './utils';
|
|
3
4
|
export declare enum CoingeckoAssetPlatform {
|
|
4
5
|
Ethereum = "ethereum",
|
|
5
6
|
Cosmos = "cosmos",
|
|
6
|
-
|
|
7
|
+
Polygon = "polygon-pos",
|
|
8
|
+
Gnosis = "xdai",
|
|
7
9
|
Avalanche = "avalanche",
|
|
8
10
|
Thorchain = "thorchain",
|
|
11
|
+
Mayachain = "cacao",
|
|
9
12
|
Optimism = "optimistic-ethereum",
|
|
10
|
-
BnbSmartChain = "binance-smart-chain"
|
|
13
|
+
BnbSmartChain = "binance-smart-chain",
|
|
14
|
+
Arbitrum = "arbitrum-one",
|
|
15
|
+
ArbitrumNova = "arbitrum-nova",
|
|
16
|
+
Base = "base",
|
|
17
|
+
Solana = "solana"
|
|
11
18
|
}
|
|
12
|
-
|
|
13
|
-
export declare const coingeckoBaseUrl = "https://api.
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const coingeckoUrl = "https://api.coingecko.com/api/v3/coins/list?include_platform=true";
|
|
19
|
+
type CoinGeckoId = string;
|
|
20
|
+
export declare const coingeckoBaseUrl = "https://api.proxy.shapeshift.com/api/v1/markets";
|
|
21
|
+
export declare const coingeckoUrl = "https://api.proxy.shapeshift.com/api/v1/markets/coins/list?include_platform=true";
|
|
16
22
|
export declare const coingeckoToAssetIds: (id: CoinGeckoId) => AssetId[];
|
|
17
23
|
export declare const assetIdToCoingecko: (assetId: AssetId) => CoinGeckoId | undefined;
|
|
18
24
|
export declare const chainIdToCoingeckoAssetPlatform: (chainId: ChainId) => string;
|
|
19
|
-
export declare const
|
|
20
|
-
|
|
21
|
-
maybeApiKeyQueryParam: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const makeCoingeckoAssetUrl: (assetId: AssetId, apiKey?: string | undefined) => string | undefined;
|
|
24
|
-
export {};
|
|
25
|
+
export declare const coingeckoAssetPlatformToChainId: (platform: CoingeckoAssetPlatform) => ChainId | undefined;
|
|
26
|
+
export declare const makeCoingeckoAssetUrl: (assetId: AssetId) => string | undefined;
|
|
@@ -1,113 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.makeCoingeckoAssetUrl = exports.makeCoingeckoUrlParts = exports.chainIdToCoingeckoAssetPlatform = exports.assetIdToCoingecko = exports.coingeckoToAssetIds = exports.coingeckoUrl = exports.coingeckoProBaseUrl = exports.coingeckoBaseUrl = exports.CoingeckoAssetPlatform = void 0;
|
|
30
|
-
const invertBy_1 = __importDefault(require("lodash/invertBy"));
|
|
31
|
-
const toLower_1 = __importDefault(require("lodash/toLower"));
|
|
32
|
-
const assetId_1 = require("../../assetId/assetId");
|
|
33
|
-
const chainId_1 = require("../../chainId/chainId");
|
|
34
|
-
const constants_1 = require("../../constants");
|
|
35
|
-
const adapters = __importStar(require("./generated"));
|
|
1
|
+
import invertBy from 'lodash/invertBy';
|
|
2
|
+
import { fromAssetId } from '../../assetId/assetId';
|
|
3
|
+
import { fromChainId, toChainId } from '../../chainId/chainId';
|
|
4
|
+
import { arbitrumChainId, arbitrumNovaChainId, avalancheChainId, baseChainId, bscChainId, CHAIN_NAMESPACE, CHAIN_REFERENCE, cosmosChainId, ethChainId, gnosisChainId, mayachainChainId, optimismChainId, polygonChainId, solanaChainId, thorchainChainId, } from '../../constants';
|
|
5
|
+
import * as adapters from './generated';
|
|
6
|
+
export { fetchData as fetchCoingeckoData, parseData as parseCoingeckoData } from './utils';
|
|
36
7
|
// https://api.coingecko.com/api/v3/asset_platforms
|
|
37
|
-
var CoingeckoAssetPlatform;
|
|
8
|
+
export var CoingeckoAssetPlatform;
|
|
38
9
|
(function (CoingeckoAssetPlatform) {
|
|
39
10
|
CoingeckoAssetPlatform["Ethereum"] = "ethereum";
|
|
40
11
|
CoingeckoAssetPlatform["Cosmos"] = "cosmos";
|
|
41
|
-
CoingeckoAssetPlatform["
|
|
12
|
+
CoingeckoAssetPlatform["Polygon"] = "polygon-pos";
|
|
13
|
+
CoingeckoAssetPlatform["Gnosis"] = "xdai";
|
|
42
14
|
CoingeckoAssetPlatform["Avalanche"] = "avalanche";
|
|
43
15
|
CoingeckoAssetPlatform["Thorchain"] = "thorchain";
|
|
16
|
+
CoingeckoAssetPlatform["Mayachain"] = "cacao";
|
|
44
17
|
CoingeckoAssetPlatform["Optimism"] = "optimistic-ethereum";
|
|
45
18
|
CoingeckoAssetPlatform["BnbSmartChain"] = "binance-smart-chain";
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
CoingeckoAssetPlatform["Arbitrum"] = "arbitrum-one";
|
|
20
|
+
CoingeckoAssetPlatform["ArbitrumNova"] = "arbitrum-nova";
|
|
21
|
+
CoingeckoAssetPlatform["Base"] = "base";
|
|
22
|
+
CoingeckoAssetPlatform["Solana"] = "solana";
|
|
23
|
+
})(CoingeckoAssetPlatform || (CoingeckoAssetPlatform = {}));
|
|
24
|
+
export const coingeckoBaseUrl = 'https://api.proxy.shapeshift.com/api/v1/markets';
|
|
25
|
+
export const coingeckoUrl = `${coingeckoBaseUrl}/coins/list?include_platform=true`;
|
|
50
26
|
const assetIdToCoinGeckoIdMapByChain = Object.values(adapters);
|
|
51
27
|
const generatedAssetIdToCoingeckoMap = assetIdToCoinGeckoIdMapByChain.reduce((acc, cur) => ({
|
|
52
28
|
...acc,
|
|
53
29
|
...cur,
|
|
54
30
|
}));
|
|
55
|
-
const generatedCoingeckoToAssetIdsMap = (
|
|
56
|
-
const coingeckoToAssetIds = (id) => generatedCoingeckoToAssetIdsMap[id];
|
|
57
|
-
|
|
58
|
-
const assetIdToCoingecko = (assetId) => generatedAssetIdToCoingeckoMap[(0, toLower_1.default)(assetId)];
|
|
59
|
-
exports.assetIdToCoingecko = assetIdToCoingecko;
|
|
31
|
+
const generatedCoingeckoToAssetIdsMap = invertBy(generatedAssetIdToCoingeckoMap);
|
|
32
|
+
export const coingeckoToAssetIds = (id) => generatedCoingeckoToAssetIdsMap[id];
|
|
33
|
+
export const assetIdToCoingecko = (assetId) => generatedAssetIdToCoingeckoMap[assetId];
|
|
60
34
|
// https://www.coingecko.com/en/api/documentation - See asset_platforms
|
|
61
|
-
const chainIdToCoingeckoAssetPlatform = (chainId) => {
|
|
62
|
-
const { chainNamespace, chainReference } =
|
|
35
|
+
export const chainIdToCoingeckoAssetPlatform = (chainId) => {
|
|
36
|
+
const { chainNamespace, chainReference } = fromChainId(chainId);
|
|
63
37
|
switch (chainNamespace) {
|
|
64
|
-
case
|
|
38
|
+
case CHAIN_NAMESPACE.Evm:
|
|
65
39
|
switch (chainReference) {
|
|
66
|
-
case
|
|
40
|
+
case CHAIN_REFERENCE.EthereumMainnet:
|
|
67
41
|
return CoingeckoAssetPlatform.Ethereum;
|
|
68
|
-
case
|
|
42
|
+
case CHAIN_REFERENCE.AvalancheCChain:
|
|
69
43
|
return CoingeckoAssetPlatform.Avalanche;
|
|
70
|
-
case
|
|
44
|
+
case CHAIN_REFERENCE.OptimismMainnet:
|
|
71
45
|
return CoingeckoAssetPlatform.Optimism;
|
|
72
|
-
case
|
|
46
|
+
case CHAIN_REFERENCE.BnbSmartChainMainnet:
|
|
73
47
|
return CoingeckoAssetPlatform.BnbSmartChain;
|
|
48
|
+
case CHAIN_REFERENCE.PolygonMainnet:
|
|
49
|
+
return CoingeckoAssetPlatform.Polygon;
|
|
50
|
+
case CHAIN_REFERENCE.GnosisMainnet:
|
|
51
|
+
return CoingeckoAssetPlatform.Gnosis;
|
|
52
|
+
case CHAIN_REFERENCE.ArbitrumMainnet:
|
|
53
|
+
return CoingeckoAssetPlatform.Arbitrum;
|
|
54
|
+
case CHAIN_REFERENCE.ArbitrumNovaMainnet:
|
|
55
|
+
return CoingeckoAssetPlatform.ArbitrumNova;
|
|
56
|
+
case CHAIN_REFERENCE.BaseMainnet:
|
|
57
|
+
return CoingeckoAssetPlatform.Base;
|
|
74
58
|
default:
|
|
75
59
|
throw new Error(`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`);
|
|
76
60
|
}
|
|
77
|
-
case
|
|
61
|
+
case CHAIN_NAMESPACE.CosmosSdk:
|
|
78
62
|
switch (chainReference) {
|
|
79
|
-
case
|
|
63
|
+
case CHAIN_REFERENCE.CosmosHubMainnet:
|
|
80
64
|
return CoingeckoAssetPlatform.Cosmos;
|
|
81
|
-
case
|
|
82
|
-
return CoingeckoAssetPlatform.Osmosis;
|
|
83
|
-
case constants_1.CHAIN_REFERENCE.ThorchainMainnet:
|
|
65
|
+
case CHAIN_REFERENCE.ThorchainMainnet:
|
|
84
66
|
return CoingeckoAssetPlatform.Thorchain;
|
|
67
|
+
case CHAIN_REFERENCE.MayachainMainnet:
|
|
68
|
+
return CoingeckoAssetPlatform.Mayachain;
|
|
69
|
+
default:
|
|
70
|
+
throw new Error(`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`);
|
|
71
|
+
}
|
|
72
|
+
case CHAIN_NAMESPACE.Solana:
|
|
73
|
+
switch (chainReference) {
|
|
74
|
+
case CHAIN_REFERENCE.SolanaMainnet:
|
|
75
|
+
return CoingeckoAssetPlatform.Solana;
|
|
85
76
|
default:
|
|
86
77
|
throw new Error(`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`);
|
|
87
78
|
}
|
|
88
79
|
// No valid asset platform: https://api.coingecko.com/api/v3/asset_platforms
|
|
89
|
-
case
|
|
80
|
+
case CHAIN_NAMESPACE.Utxo:
|
|
90
81
|
default:
|
|
91
82
|
throw new Error(`chainNamespace ${chainNamespace} not supported.`);
|
|
92
83
|
}
|
|
93
84
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
export const coingeckoAssetPlatformToChainId = (platform) => {
|
|
86
|
+
switch (platform) {
|
|
87
|
+
case CoingeckoAssetPlatform.Ethereum:
|
|
88
|
+
return ethChainId;
|
|
89
|
+
case CoingeckoAssetPlatform.Avalanche:
|
|
90
|
+
return avalancheChainId;
|
|
91
|
+
case CoingeckoAssetPlatform.Optimism:
|
|
92
|
+
return optimismChainId;
|
|
93
|
+
case CoingeckoAssetPlatform.BnbSmartChain:
|
|
94
|
+
return bscChainId;
|
|
95
|
+
case CoingeckoAssetPlatform.Polygon:
|
|
96
|
+
return polygonChainId;
|
|
97
|
+
case CoingeckoAssetPlatform.Gnosis:
|
|
98
|
+
return gnosisChainId;
|
|
99
|
+
case CoingeckoAssetPlatform.Arbitrum:
|
|
100
|
+
return arbitrumChainId;
|
|
101
|
+
case CoingeckoAssetPlatform.ArbitrumNova:
|
|
102
|
+
return arbitrumNovaChainId;
|
|
103
|
+
case CoingeckoAssetPlatform.Base:
|
|
104
|
+
return baseChainId;
|
|
105
|
+
case CoingeckoAssetPlatform.Cosmos:
|
|
106
|
+
return cosmosChainId;
|
|
107
|
+
case CoingeckoAssetPlatform.Thorchain:
|
|
108
|
+
return thorchainChainId;
|
|
109
|
+
case CoingeckoAssetPlatform.Mayachain:
|
|
110
|
+
return mayachainChainId;
|
|
111
|
+
case CoingeckoAssetPlatform.Solana:
|
|
112
|
+
return solanaChainId;
|
|
113
|
+
default:
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
99
116
|
};
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const id = (0, exports.assetIdToCoingecko)(assetId);
|
|
117
|
+
export const makeCoingeckoAssetUrl = (assetId) => {
|
|
118
|
+
const id = assetIdToCoingecko(assetId);
|
|
103
119
|
if (!id)
|
|
104
120
|
return;
|
|
105
|
-
const {
|
|
106
|
-
const { chainNamespace, chainReference, assetNamespace, assetReference } = (0, assetId_1.fromAssetId)(assetId);
|
|
121
|
+
const { chainNamespace, chainReference, assetNamespace, assetReference } = fromAssetId(assetId);
|
|
107
122
|
if (assetNamespace === 'erc20') {
|
|
108
|
-
const assetPlatform =
|
|
109
|
-
return `${
|
|
123
|
+
const assetPlatform = chainIdToCoingeckoAssetPlatform(toChainId({ chainNamespace, chainReference }));
|
|
124
|
+
return `${coingeckoBaseUrl}/coins/${assetPlatform}/contract/${assetReference}`;
|
|
110
125
|
}
|
|
111
|
-
return `${
|
|
126
|
+
return `${coingeckoBaseUrl}/coins/${id}`;
|
|
112
127
|
};
|
|
113
|
-
exports.makeCoingeckoAssetUrl = makeCoingeckoAssetUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { toAssetId } from '../../assetId/assetId';
|
|
3
|
+
import { ASSET_REFERENCE, btcChainId, CHAIN_NAMESPACE, CHAIN_REFERENCE, ethChainId, foxOnArbitrumOneAssetId, } from '../../constants';
|
|
4
|
+
import { assetIdToCoingecko, chainIdToCoingeckoAssetPlatform, CoingeckoAssetPlatform, coingeckoToAssetIds, } from '.';
|
|
5
|
+
describe('adapters:coingecko', () => {
|
|
6
|
+
describe('coingeckoToAssetIds', () => {
|
|
7
|
+
it('can get AssetIds for bitcoin', () => {
|
|
8
|
+
const chainNamespace = CHAIN_NAMESPACE.Utxo;
|
|
9
|
+
const chainReference = CHAIN_REFERENCE.BitcoinMainnet;
|
|
10
|
+
const assetId = toAssetId({
|
|
11
|
+
chainNamespace,
|
|
12
|
+
chainReference,
|
|
13
|
+
assetNamespace: 'slip44',
|
|
14
|
+
assetReference: ASSET_REFERENCE.Bitcoin,
|
|
15
|
+
});
|
|
16
|
+
expect(coingeckoToAssetIds('bitcoin')).toEqual([assetId]);
|
|
17
|
+
});
|
|
18
|
+
it('can get AssetIds id for ethereum', () => {
|
|
19
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
20
|
+
const ethOnEthereum = toAssetId({
|
|
21
|
+
chainNamespace,
|
|
22
|
+
chainReference: CHAIN_REFERENCE.EthereumMainnet,
|
|
23
|
+
assetNamespace: 'slip44',
|
|
24
|
+
assetReference: ASSET_REFERENCE.Ethereum,
|
|
25
|
+
});
|
|
26
|
+
const ethOnOptimism = toAssetId({
|
|
27
|
+
chainNamespace,
|
|
28
|
+
chainReference: CHAIN_REFERENCE.OptimismMainnet,
|
|
29
|
+
assetNamespace: 'slip44',
|
|
30
|
+
assetReference: ASSET_REFERENCE.Optimism,
|
|
31
|
+
});
|
|
32
|
+
const ethOnArbitrum = toAssetId({
|
|
33
|
+
chainNamespace,
|
|
34
|
+
chainReference: CHAIN_REFERENCE.ArbitrumMainnet,
|
|
35
|
+
assetNamespace: 'slip44',
|
|
36
|
+
assetReference: ASSET_REFERENCE.Arbitrum,
|
|
37
|
+
});
|
|
38
|
+
const ethOnArbitrumNova = toAssetId({
|
|
39
|
+
chainNamespace,
|
|
40
|
+
chainReference: CHAIN_REFERENCE.ArbitrumNovaMainnet,
|
|
41
|
+
assetNamespace: 'slip44',
|
|
42
|
+
assetReference: ASSET_REFERENCE.ArbitrumNova,
|
|
43
|
+
});
|
|
44
|
+
const ethOnBase = toAssetId({
|
|
45
|
+
chainNamespace,
|
|
46
|
+
chainReference: CHAIN_REFERENCE.BaseMainnet,
|
|
47
|
+
assetNamespace: 'slip44',
|
|
48
|
+
assetReference: ASSET_REFERENCE.Base,
|
|
49
|
+
});
|
|
50
|
+
expect(coingeckoToAssetIds('ethereum')).toEqual([
|
|
51
|
+
ethOnEthereum,
|
|
52
|
+
ethOnOptimism,
|
|
53
|
+
ethOnArbitrum,
|
|
54
|
+
ethOnArbitrumNova,
|
|
55
|
+
ethOnBase,
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
it('can get AssetIds id for FOX', () => {
|
|
59
|
+
const assetNamespace = 'erc20';
|
|
60
|
+
const foxOnEthereum = toAssetId({
|
|
61
|
+
chainNamespace: CHAIN_NAMESPACE.Evm,
|
|
62
|
+
chainReference: CHAIN_REFERENCE.EthereumMainnet,
|
|
63
|
+
assetNamespace,
|
|
64
|
+
assetReference: '0xc770eefad204b5180df6a14ee197d99d808ee52d',
|
|
65
|
+
});
|
|
66
|
+
const foxOnPolygon = toAssetId({
|
|
67
|
+
chainNamespace: CHAIN_NAMESPACE.Evm,
|
|
68
|
+
chainReference: CHAIN_REFERENCE.PolygonMainnet,
|
|
69
|
+
assetNamespace,
|
|
70
|
+
assetReference: '0x65a05db8322701724c197af82c9cae41195b0aa8',
|
|
71
|
+
});
|
|
72
|
+
const foxOnGnosis = toAssetId({
|
|
73
|
+
chainNamespace: CHAIN_NAMESPACE.Evm,
|
|
74
|
+
chainReference: CHAIN_REFERENCE.GnosisMainnet,
|
|
75
|
+
assetNamespace,
|
|
76
|
+
assetReference: '0x21a42669643f45bc0e086b8fc2ed70c23d67509d',
|
|
77
|
+
});
|
|
78
|
+
const foxOnOptimism = toAssetId({
|
|
79
|
+
chainNamespace: CHAIN_NAMESPACE.Evm,
|
|
80
|
+
chainReference: CHAIN_REFERENCE.OptimismMainnet,
|
|
81
|
+
assetNamespace,
|
|
82
|
+
assetReference: '0xf1a0da3367bc7aa04f8d94ba57b862ff37ced174',
|
|
83
|
+
});
|
|
84
|
+
expect(coingeckoToAssetIds('shapeshift-fox-token')).toEqual([
|
|
85
|
+
foxOnEthereum,
|
|
86
|
+
foxOnOptimism,
|
|
87
|
+
foxOnPolygon,
|
|
88
|
+
foxOnGnosis,
|
|
89
|
+
foxOnArbitrumOneAssetId,
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
it('can get AssetIds for cosmos', () => {
|
|
93
|
+
const atomOnCosmos = toAssetId({
|
|
94
|
+
chainNamespace: CHAIN_NAMESPACE.CosmosSdk,
|
|
95
|
+
chainReference: CHAIN_REFERENCE.CosmosHubMainnet,
|
|
96
|
+
assetNamespace: 'slip44',
|
|
97
|
+
assetReference: ASSET_REFERENCE.Cosmos,
|
|
98
|
+
});
|
|
99
|
+
const atomOnBsc = toAssetId({
|
|
100
|
+
chainNamespace: CHAIN_NAMESPACE.Evm,
|
|
101
|
+
chainReference: CHAIN_REFERENCE.BnbSmartChainMainnet,
|
|
102
|
+
assetNamespace: 'bep20',
|
|
103
|
+
assetReference: '0x0eb3a705fc54725037cc9e008bdede697f62f335',
|
|
104
|
+
});
|
|
105
|
+
expect(coingeckoToAssetIds('cosmos')).toEqual([atomOnBsc, atomOnCosmos]);
|
|
106
|
+
});
|
|
107
|
+
it('can get AssetIds for USD Coin on Solana and EVM chains using coingecko', () => {
|
|
108
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
109
|
+
const assetNamespace = 'erc20';
|
|
110
|
+
const usdcOnEthereum = toAssetId({
|
|
111
|
+
chainNamespace,
|
|
112
|
+
chainReference: CHAIN_REFERENCE.EthereumMainnet,
|
|
113
|
+
assetNamespace,
|
|
114
|
+
assetReference: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
115
|
+
});
|
|
116
|
+
const usdcOnAvalanche = toAssetId({
|
|
117
|
+
chainNamespace,
|
|
118
|
+
chainReference: CHAIN_REFERENCE.AvalancheCChain,
|
|
119
|
+
assetNamespace,
|
|
120
|
+
assetReference: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
121
|
+
});
|
|
122
|
+
const usdcOnOptimism = toAssetId({
|
|
123
|
+
chainNamespace,
|
|
124
|
+
chainReference: CHAIN_REFERENCE.OptimismMainnet,
|
|
125
|
+
assetNamespace,
|
|
126
|
+
assetReference: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
127
|
+
});
|
|
128
|
+
const usdcOnPolygon = toAssetId({
|
|
129
|
+
chainNamespace,
|
|
130
|
+
chainReference: CHAIN_REFERENCE.PolygonMainnet,
|
|
131
|
+
assetNamespace,
|
|
132
|
+
assetReference: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
|
|
133
|
+
});
|
|
134
|
+
const usdcOnArbitrum = toAssetId({
|
|
135
|
+
chainNamespace,
|
|
136
|
+
chainReference: CHAIN_REFERENCE.ArbitrumMainnet,
|
|
137
|
+
assetNamespace,
|
|
138
|
+
assetReference: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
|
|
139
|
+
});
|
|
140
|
+
const usdcOnBase = toAssetId({
|
|
141
|
+
chainNamespace,
|
|
142
|
+
chainReference: CHAIN_REFERENCE.BaseMainnet,
|
|
143
|
+
assetNamespace,
|
|
144
|
+
assetReference: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
145
|
+
});
|
|
146
|
+
const usdcOnSolana = toAssetId({
|
|
147
|
+
chainNamespace: CHAIN_NAMESPACE.Solana,
|
|
148
|
+
chainReference: CHAIN_REFERENCE.SolanaMainnet,
|
|
149
|
+
assetNamespace: 'token',
|
|
150
|
+
assetReference: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
151
|
+
});
|
|
152
|
+
expect(coingeckoToAssetIds('usd-coin')).toEqual([
|
|
153
|
+
usdcOnEthereum,
|
|
154
|
+
usdcOnAvalanche,
|
|
155
|
+
usdcOnOptimism,
|
|
156
|
+
usdcOnPolygon,
|
|
157
|
+
usdcOnArbitrum,
|
|
158
|
+
usdcOnBase,
|
|
159
|
+
usdcOnSolana,
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
it('can get AssetIds for bridged USD Coin on EVM Chains', () => {
|
|
163
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
164
|
+
const assetNamespace = 'erc20';
|
|
165
|
+
const usdcOnBscBridged = toAssetId({
|
|
166
|
+
chainNamespace,
|
|
167
|
+
chainReference: CHAIN_REFERENCE.BnbSmartChainMainnet,
|
|
168
|
+
assetNamespace: 'bep20',
|
|
169
|
+
assetReference: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
|
|
170
|
+
});
|
|
171
|
+
const usdcOnPolygonBridged = toAssetId({
|
|
172
|
+
chainNamespace,
|
|
173
|
+
chainReference: CHAIN_REFERENCE.PolygonMainnet,
|
|
174
|
+
assetNamespace,
|
|
175
|
+
assetReference: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
|
|
176
|
+
});
|
|
177
|
+
const usdcOnArbitrumNovaBridged = toAssetId({
|
|
178
|
+
chainNamespace,
|
|
179
|
+
chainReference: CHAIN_REFERENCE.ArbitrumNovaMainnet,
|
|
180
|
+
assetNamespace,
|
|
181
|
+
assetReference: '0x750ba8b76187092B0D1E87E28daaf484d1b5273b',
|
|
182
|
+
});
|
|
183
|
+
const usdcOnGnosisBridged = toAssetId({
|
|
184
|
+
chainNamespace,
|
|
185
|
+
chainReference: CHAIN_REFERENCE.GnosisMainnet,
|
|
186
|
+
assetNamespace,
|
|
187
|
+
assetReference: '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83',
|
|
188
|
+
});
|
|
189
|
+
expect(coingeckoToAssetIds('binance-bridged-usdc-bnb-smart-chain')).toEqual([
|
|
190
|
+
usdcOnBscBridged,
|
|
191
|
+
]);
|
|
192
|
+
expect(coingeckoToAssetIds('bridged-usdc-polygon-pos-bridge')).toEqual([usdcOnPolygonBridged]);
|
|
193
|
+
expect(coingeckoToAssetIds('gnosis-xdai-bridged-usdc-gnosis')).toEqual([usdcOnGnosisBridged]);
|
|
194
|
+
expect(coingeckoToAssetIds('official-arbitrum-bridged-usdc-arbitrum-nova')).toEqual([
|
|
195
|
+
usdcOnArbitrumNovaBridged,
|
|
196
|
+
]);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe('assetIdToCoingecko', () => {
|
|
200
|
+
it('can get CoinGecko id for bitcoin AssetId', () => {
|
|
201
|
+
const chainNamespace = CHAIN_NAMESPACE.Utxo;
|
|
202
|
+
const chainReference = CHAIN_REFERENCE.BitcoinMainnet;
|
|
203
|
+
const assetId = toAssetId({
|
|
204
|
+
chainNamespace,
|
|
205
|
+
chainReference,
|
|
206
|
+
assetNamespace: 'slip44',
|
|
207
|
+
assetReference: ASSET_REFERENCE.Bitcoin,
|
|
208
|
+
});
|
|
209
|
+
expect(assetIdToCoingecko(assetId)).toEqual('bitcoin');
|
|
210
|
+
});
|
|
211
|
+
it('can get CoinGecko id for ethereum AssetId', () => {
|
|
212
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
213
|
+
const chainReference = CHAIN_REFERENCE.EthereumMainnet;
|
|
214
|
+
const assetId = toAssetId({
|
|
215
|
+
chainNamespace,
|
|
216
|
+
chainReference,
|
|
217
|
+
assetNamespace: 'slip44',
|
|
218
|
+
assetReference: ASSET_REFERENCE.Ethereum,
|
|
219
|
+
});
|
|
220
|
+
expect(assetIdToCoingecko(assetId)).toEqual('ethereum');
|
|
221
|
+
});
|
|
222
|
+
it('can get CoinGecko id for FOX', () => {
|
|
223
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
224
|
+
const chainReference = CHAIN_REFERENCE.EthereumMainnet;
|
|
225
|
+
const assetNamespace = 'erc20';
|
|
226
|
+
const assetReference = '0xc770eefad204b5180df6a14ee197d99d808ee52d';
|
|
227
|
+
const assetId = toAssetId({ chainNamespace, chainReference, assetNamespace, assetReference });
|
|
228
|
+
expect(assetIdToCoingecko(assetId)).toEqual('shapeshift-fox-token');
|
|
229
|
+
});
|
|
230
|
+
it('can get CoinGecko id for cosmos AssetId', () => {
|
|
231
|
+
const chainNamespace = CHAIN_NAMESPACE.CosmosSdk;
|
|
232
|
+
const chainReference = CHAIN_REFERENCE.CosmosHubMainnet;
|
|
233
|
+
const assetId = toAssetId({
|
|
234
|
+
chainNamespace,
|
|
235
|
+
chainReference,
|
|
236
|
+
assetNamespace: 'slip44',
|
|
237
|
+
assetReference: ASSET_REFERENCE.Cosmos,
|
|
238
|
+
});
|
|
239
|
+
expect(assetIdToCoingecko(assetId)).toEqual('cosmos');
|
|
240
|
+
});
|
|
241
|
+
it('can get CoinGecko id for polygon AssetId', () => {
|
|
242
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
243
|
+
const chainReference = CHAIN_REFERENCE.PolygonMainnet;
|
|
244
|
+
const assetId = toAssetId({
|
|
245
|
+
chainNamespace,
|
|
246
|
+
chainReference,
|
|
247
|
+
assetNamespace: 'slip44',
|
|
248
|
+
assetReference: ASSET_REFERENCE.Polygon,
|
|
249
|
+
});
|
|
250
|
+
expect(assetIdToCoingecko(assetId)).toEqual('matic-network');
|
|
251
|
+
});
|
|
252
|
+
it('can get CoinGecko id for gnosis AssetId', () => {
|
|
253
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm;
|
|
254
|
+
const chainReference = CHAIN_REFERENCE.GnosisMainnet;
|
|
255
|
+
const assetId = toAssetId({
|
|
256
|
+
chainNamespace,
|
|
257
|
+
chainReference,
|
|
258
|
+
assetNamespace: 'slip44',
|
|
259
|
+
assetReference: ASSET_REFERENCE.Gnosis,
|
|
260
|
+
});
|
|
261
|
+
expect(assetIdToCoingecko(assetId)).toEqual('xdai');
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
describe('chainIdToCoingeckoAssetPlatform', () => {
|
|
265
|
+
it('can get CoinGecko asset platform from ChainId', () => {
|
|
266
|
+
const chainId = ethChainId;
|
|
267
|
+
expect(chainIdToCoingeckoAssetPlatform(chainId)).toEqual(CoingeckoAssetPlatform.Ethereum);
|
|
268
|
+
});
|
|
269
|
+
it('throws on invalid ChainId', () => {
|
|
270
|
+
const chainId = btcChainId;
|
|
271
|
+
expect(() => chainIdToCoingeckoAssetPlatform(chainId)).toThrow();
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { AssetId } from '../../assetId/assetId';
|
|
2
|
-
import { ChainId } from '../../chainId/chainId';
|
|
3
|
-
export
|
|
1
|
+
import type { AssetId } from '../../assetId/assetId';
|
|
2
|
+
import type { ChainId } from '../../chainId/chainId';
|
|
3
|
+
export type CoingeckoCoin = {
|
|
4
4
|
id: string;
|
|
5
|
-
symbol: string;
|
|
6
|
-
name: string;
|
|
7
5
|
platforms: Record<string, string>;
|
|
8
6
|
};
|
|
9
|
-
|
|
7
|
+
type AssetMap = Record<ChainId, Record<AssetId, string>>;
|
|
10
8
|
export declare const fetchData: (URL: string) => Promise<CoingeckoCoin[]>;
|
|
11
9
|
export declare const parseData: (coins: CoingeckoCoin[]) => AssetMap;
|
|
12
10
|
export declare const writeFiles: (data: AssetMap) => Promise<void>;
|