@shapeshiftoss/caip 6.15.1 → 8.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.
- package/README.md +5 -5
- package/dist/accountId/accountId.js +2 -2
- package/dist/adapters/coincap/utils.js +1 -1
- package/dist/adapters/coingecko/index.js +3 -3
- package/dist/adapters/coingecko/utils.js +2 -2
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js +1 -0
- package/dist/adapters/mtpelerin/index.d.ts +72 -0
- package/dist/adapters/mtpelerin/index.js +125 -0
- package/dist/adapters/osmosis/utils.js +2 -2
- package/dist/adapters/yearn/utils.js +2 -2
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Usage
|
|
|
12
12
|
### `toChainId` | `toCAIP2`
|
|
13
13
|
|
|
14
14
|
```ts
|
|
15
|
-
const chainNamespace = CHAIN_NAMESPACE.
|
|
15
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm
|
|
16
16
|
const chainReference = CHAIN_REFERENCE.EthereumMainnet
|
|
17
17
|
const result = toChainId({ chainNamespace, chainReference })
|
|
18
18
|
expect(result).toEqual('eip155:1')
|
|
@@ -23,7 +23,7 @@ expect(result).toEqual('eip155:1')
|
|
|
23
23
|
```ts
|
|
24
24
|
const ethereumChainId = 'eip155:1'
|
|
25
25
|
const { chainNamespace, chainReference } = fromChainId(ethereumChainId)
|
|
26
|
-
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.
|
|
26
|
+
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
|
|
27
27
|
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumMainnet)
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -36,7 +36,7 @@ Usage
|
|
|
36
36
|
### `toAccountId` | `toCAIP10`
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
const chainNamespace = CHAIN_NAMESPACE.
|
|
39
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm
|
|
40
40
|
const chainReference = CHAIN_REFERENCE.EthereumMainnet
|
|
41
41
|
const chainId = toChainId({ chainNamespace, chainReference })
|
|
42
42
|
const account = '0xa44c286ba83bb771cd0107b2c1df678435bd1535'
|
|
@@ -67,7 +67,7 @@ Usage
|
|
|
67
67
|
Ether
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
|
-
const chainNamespace = CHAIN_NAMESPACE.
|
|
70
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm
|
|
71
71
|
const chainReference = CHAIN_REFERENCE.EthereumMainnet
|
|
72
72
|
const chainId = toChainId({ chainNamespace, chainReference })
|
|
73
73
|
const assetNamespace = 'slip44'
|
|
@@ -79,7 +79,7 @@ expect(toAssetId({ chainId, assetNamespace, assetReference })).toEqual('eip155:1
|
|
|
79
79
|
ERC20 token
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
|
-
const chainNamespace = CHAIN_NAMESPACE.
|
|
82
|
+
const chainNamespace = CHAIN_NAMESPACE.Evm
|
|
83
83
|
const chainReference = CHAIN_REFERENCE.EthereumMainnet
|
|
84
84
|
const chainId = toChainId({ chainNamespace, chainReference })
|
|
85
85
|
const assetNamespace = 'erc20'
|
|
@@ -13,7 +13,7 @@ const toAccountId = ({ chainId: maybeChainId, chainNamespace: maybeChainNamespac
|
|
|
13
13
|
// we lowercase eth accounts as per the draft spec
|
|
14
14
|
// it's not explicit, but cHecKsUM can be recovered from lowercase eth accounts
|
|
15
15
|
// we don't lowercase bitcoin addresses as they'll fail checksum
|
|
16
|
-
const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.
|
|
16
|
+
const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.Evm ? account.toLowerCase() : account;
|
|
17
17
|
return `${chainId}:${outputAccount}`;
|
|
18
18
|
};
|
|
19
19
|
exports.toAccountId = toAccountId;
|
|
@@ -35,7 +35,7 @@ const fromAccountId = (accountId) => {
|
|
|
35
35
|
// we lowercase eth accounts as per the draft spec
|
|
36
36
|
// it's not explicit, but cHecKsUM can be recovered from lowercase eth accounts
|
|
37
37
|
// we don't lowercase bitcoin addresses as they'll fail checksum
|
|
38
|
-
const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.
|
|
38
|
+
const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.Evm ? account.toLowerCase() : account;
|
|
39
39
|
return { chainId, account: outputAccount, chainNamespace, chainReference };
|
|
40
40
|
};
|
|
41
41
|
exports.fromAccountId = fromAccountId;
|
|
@@ -22,7 +22,7 @@ exports.fetchData = fetchData;
|
|
|
22
22
|
const parseEthData = (data) => {
|
|
23
23
|
const ethCoins = data.filter(({ id, explorer }) => (explorer && explorer.startsWith('https://etherscan.io/token/0x')) || id === 'ethereum');
|
|
24
24
|
return ethCoins.reduce((acc, { id, explorer }) => {
|
|
25
|
-
const chainNamespace = constants_1.CHAIN_NAMESPACE.
|
|
25
|
+
const chainNamespace = constants_1.CHAIN_NAMESPACE.Evm;
|
|
26
26
|
const chainReference = constants_1.CHAIN_REFERENCE.EthereumMainnet;
|
|
27
27
|
let assetReference = constants_1.ASSET_REFERENCE.Ethereum;
|
|
28
28
|
const assetNamespace = id === 'ethereum' ? 'slip44' : 'erc20';
|
|
@@ -58,7 +58,7 @@ exports.assetIdToCoingecko = assetIdToCoingecko;
|
|
|
58
58
|
const chainIdToCoingeckoAssetPlatform = (chainId) => {
|
|
59
59
|
const { chainNamespace, chainReference } = (0, chainId_1.fromChainId)(chainId);
|
|
60
60
|
switch (chainNamespace) {
|
|
61
|
-
case constants_1.CHAIN_NAMESPACE.
|
|
61
|
+
case constants_1.CHAIN_NAMESPACE.Evm:
|
|
62
62
|
switch (chainReference) {
|
|
63
63
|
case constants_1.CHAIN_REFERENCE.EthereumMainnet:
|
|
64
64
|
return CoingeckoAssetPlatform.Ethereum;
|
|
@@ -67,7 +67,7 @@ const chainIdToCoingeckoAssetPlatform = (chainId) => {
|
|
|
67
67
|
default:
|
|
68
68
|
throw new Error(`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`);
|
|
69
69
|
}
|
|
70
|
-
case constants_1.CHAIN_NAMESPACE.
|
|
70
|
+
case constants_1.CHAIN_NAMESPACE.CosmosSdk:
|
|
71
71
|
switch (chainReference) {
|
|
72
72
|
case constants_1.CHAIN_REFERENCE.CosmosHubMainnet:
|
|
73
73
|
return CoingeckoAssetPlatform.Cosmos;
|
|
@@ -77,7 +77,7 @@ const chainIdToCoingeckoAssetPlatform = (chainId) => {
|
|
|
77
77
|
throw new Error(`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`);
|
|
78
78
|
}
|
|
79
79
|
// No valid asset platform: https://api.coingecko.com/api/v3/asset_platforms
|
|
80
|
-
case constants_1.CHAIN_NAMESPACE.
|
|
80
|
+
case constants_1.CHAIN_NAMESPACE.Utxo:
|
|
81
81
|
default:
|
|
82
82
|
throw new Error(`chainNamespace ${chainNamespace} not supported.`);
|
|
83
83
|
}
|
|
@@ -16,7 +16,7 @@ const parseData = (coins) => {
|
|
|
16
16
|
if (Object.keys(platforms).includes('ethereum')) {
|
|
17
17
|
try {
|
|
18
18
|
const assetId = (0, assetId_1.toAssetId)({
|
|
19
|
-
chainNamespace: constants_1.CHAIN_NAMESPACE.
|
|
19
|
+
chainNamespace: constants_1.CHAIN_NAMESPACE.Evm,
|
|
20
20
|
chainReference: constants_1.CHAIN_REFERENCE.EthereumMainnet,
|
|
21
21
|
assetNamespace: 'erc20',
|
|
22
22
|
assetReference: platforms.ethereum,
|
|
@@ -30,7 +30,7 @@ const parseData = (coins) => {
|
|
|
30
30
|
if (Object.keys(platforms).includes('avalanche')) {
|
|
31
31
|
try {
|
|
32
32
|
const assetId = (0, assetId_1.toAssetId)({
|
|
33
|
-
chainNamespace: constants_1.CHAIN_NAMESPACE.
|
|
33
|
+
chainNamespace: constants_1.CHAIN_NAMESPACE.Evm,
|
|
34
34
|
chainReference: constants_1.CHAIN_REFERENCE.AvalancheCChain,
|
|
35
35
|
assetNamespace: 'erc20',
|
|
36
36
|
assetReference: platforms.avalanche,
|
package/dist/adapters/index.d.ts
CHANGED
package/dist/adapters/index.js
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AssetId } from '../../assetId/assetId';
|
|
2
|
+
/**
|
|
3
|
+
* The following is the list of assets that Mt Pelerin supports
|
|
4
|
+
* but they're **not supported** (yet?) in ShapeShift
|
|
5
|
+
* {
|
|
6
|
+
'[xdai_mainnet]/0x0000000000000000000000000000000000000000': 'XDAI',
|
|
7
|
+
'[xdai_mainnet]/0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83': 'USDC',
|
|
8
|
+
'[xdai_mainnet]/0x4ECaBa5870353805a9F068101A40E0f32ed605C6': 'USDT',
|
|
9
|
+
'[xdai_mainnet]/0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252': 'WBTC',
|
|
10
|
+
'[xdai_mainnet]/0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1': 'WETH',
|
|
11
|
+
'[xdai_mainnet]/0x9fB1d52596c44603198fB0aee434fac3a679f702': 'jEUR',
|
|
12
|
+
'[xdai_mainnet]/0x2d5563da42b06FbBF9c67b7DC073cF6A7842239e': 'jCHF',
|
|
13
|
+
'[bsc_mainnet]/0x0000000000000000000000000000000000000000': 'BNB',
|
|
14
|
+
'[bsc_mainnet]/0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d': 'USDC',
|
|
15
|
+
'[bsc_mainnet]/0x55d398326f99059fF775485246999027B3197955': 'USDT',
|
|
16
|
+
'[bsc_mainnet]/0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c': 'BTCB',
|
|
17
|
+
'[bsc_mainnet]/0x2170ed0880ac9a755fd29b2688956bd959f933f8': 'WETH',
|
|
18
|
+
'[bsc_mainnet]/0xe9e7cea3dedca5984780bafc599bd69add087d56': 'BUSD',
|
|
19
|
+
'[bsc_mainnet]/0x23b8683Ff98F9E4781552DFE6f12Aa32814924e8': 'jEUR',
|
|
20
|
+
'[bsc_mainnet]/0x7c869b5A294b1314E985283d01C702B62224a05f': 'jCHF',
|
|
21
|
+
'[bsc_mainnet]/0x048E9b1ddF9EBbb224812372280e94Ccac443f9e': 'jGBP',
|
|
22
|
+
'[bsc_mainnet]/0x6B8b9AE0627a7622c593A1696859ca753c61A670': 'jZAR',
|
|
23
|
+
'[matic_mainnet]/0x0000000000000000000000000000000000000000': 'MATIC',
|
|
24
|
+
'[matic_mainnet]/0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174': 'USDC',
|
|
25
|
+
'[matic_mainnet]/0xc2132D05D31c914a87C6611C10748AEb04B58e8F': 'USDT',
|
|
26
|
+
'[matic_mainnet]/0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6': 'WBTC',
|
|
27
|
+
'[matic_mainnet]/0x4e3Decbb3645551B8A19f0eA1678079FCB33fB4c': 'jEUR',
|
|
28
|
+
'[matic_mainnet]/0xbD1463F02f61676d53fd183C2B19282BFF93D099': 'jCHF',
|
|
29
|
+
'[matic_mainnet]/0x767058F11800FBA6A682E73A6e79ec5eB74Fac8c': 'jGBP',
|
|
30
|
+
'[matic_mainnet]/0x8ca194A3b22077359b5732DE53373D4afC11DeE3': 'jCAD',
|
|
31
|
+
'[matic_mainnet]/0xa926db7a4CC0cb1736D5ac60495ca8Eb7214B503': 'jSGD',
|
|
32
|
+
'[matic_mainnet]/0x197E5d6CcfF265AC3E303a34Db360ee1429f5d1A': 'jSEK',
|
|
33
|
+
'[matic_mainnet]/0xCB7F1Ef7246D1497b985f7FC45A1A31F04346133': 'jAUD',
|
|
34
|
+
'[matic_mainnet]/0x8343091F2499FD4b6174A46D067A920a3b851FF9': 'jJPY',
|
|
35
|
+
'[matic_mainnet]/0x7ceb23fd6bc0add59e62ac25578270cff1b9f619': 'WETH',
|
|
36
|
+
'[matic_mainnet]/0xE111178A87A3BFf0c8d18DECBa5798827539Ae99': 'EURS',
|
|
37
|
+
'[matic_mainnet]/0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f': 'EURT',
|
|
38
|
+
'[matic_mainnet]/0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4': 'agEUR',
|
|
39
|
+
'[matic_mainnet]/0x45c32fA6DF82ead1e2EF74d17b76547EDdFaFF89': 'FRAX',
|
|
40
|
+
'[matic_mainnet]/0xa3Fa99A148fA48D14Ed51d610c367C61876997F1': 'MAI',
|
|
41
|
+
'[matic_mainnet]/0xE6469Ba6D2fD6130788E0eA9C0a0515900563b59': 'UST',
|
|
42
|
+
'[tezos_mainnet]/0x0000000000000000000000000000000000000000': 'XTZ',
|
|
43
|
+
'[tezos_mainnet]/KT1JBNFcB5tiycHNdYGYCtR3kk6JaJysUCi8': 'EURL',
|
|
44
|
+
'[arbitrum_mainnet]/0x0000000000000000000000000000000000000000': 'ETH',
|
|
45
|
+
'[arbitrum_mainnet]/0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8': 'USDC',
|
|
46
|
+
'[optimism_mainnet]/0x0000000000000000000000000000000000000000': 'ETH',
|
|
47
|
+
'[optimism_mainnet]/0x7F5c764cBc14f9669B88837ca1490cCa17c31607': 'USDC',
|
|
48
|
+
'[avalanche_mainnet]/0x9fB1d52596c44603198fB0aee434fac3a679f702': 'jEUR',
|
|
49
|
+
'[avalanche_mainnet]/0x2d5563da42b06FbBF9c67b7DC073cF6A7842239e': 'jCHF',
|
|
50
|
+
'[avalanche_mainnet]/0x5c49b268c9841AFF1Cc3B0a418ff5c3442eE3F3b': 'MAI',
|
|
51
|
+
'[avalanche_mainnet]/0xb599c3590F42f8F995ECfa0f85D2980B76862fc1': 'UST',
|
|
52
|
+
'[fantom_mainnet]/0x0000000000000000000000000000000000000000': 'FTM',
|
|
53
|
+
'[fantom_mainnet]/0x04068DA6C83AFCFA0e13ba15A6696662335D5B75': 'USDC',
|
|
54
|
+
'[fantom_mainnet]/0xdc301622e621166BD8E82f2cA0A26c13Ad0BE355': 'FRAX',
|
|
55
|
+
'[fantom_mainnet]/0xfB98B335551a418cD0737375a2ea0ded62Ea213b': 'MAI',
|
|
56
|
+
'[fantom_mainnet]/0x846e4D51d7E2043C1a87E0Ab7490B93FB940357b': 'UST',
|
|
57
|
+
'[rsk_mainnet]/0x0000000000000000000000000000000000000000': 'RBTC',
|
|
58
|
+
'[rsk_mainnet]/0x2d919f19d4892381d58edebeca66d5642cef1a1f': 'RDOC',
|
|
59
|
+
'[rsk_mainnet]/0xef213441a85df4d7acbdae0cf78004e1e486bb96': 'USDT',
|
|
60
|
+
'[rsk_mainnet]/0x2acc95758f8b5f583470ba265eb685a8f45fc9d5': 'RIF',
|
|
61
|
+
'[ethChainId]/0x89d71DfbDD6ebeCd0dfe27D55189F903169d2991': 'THDX'
|
|
62
|
+
* }
|
|
63
|
+
*/
|
|
64
|
+
export declare const mtPelerinSymbolToAssetIds: (id: string) => AssetId[];
|
|
65
|
+
export declare const assetIdToMtPelerinSymbol: (assetId: AssetId) => string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Convert a mtPelerin asset identifier to a MtPelerin chain identifier for use in MtPelerin HTTP URLs
|
|
68
|
+
*
|
|
69
|
+
* @param {string} assetId - an assetId string referencing a specific asset; e.g., ethAssetId
|
|
70
|
+
* @returns {string} - a MtPelerin network identifier; e.g., 'mainnet'
|
|
71
|
+
*/
|
|
72
|
+
export declare const getMtPelerinNetFromAssetId: (assetId: AssetId) => string | undefined;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMtPelerinNetFromAssetId = exports.assetIdToMtPelerinSymbol = exports.mtPelerinSymbolToAssetIds = void 0;
|
|
4
|
+
const assetId_1 = require("../../assetId/assetId");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
/**
|
|
7
|
+
* provided from https://api.mtPelerin.com/currencies/tokens
|
|
8
|
+
*/
|
|
9
|
+
const MtPelerinSymbolToAssetIds = {
|
|
10
|
+
ETH: [constants_1.ethAssetId],
|
|
11
|
+
BTC: [constants_1.btcAssetId],
|
|
12
|
+
DAI: ['eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f'],
|
|
13
|
+
USDT: ['eip155:1/erc20:0xdac17f958d2ee523a2206206994597c13d831ec7'],
|
|
14
|
+
USDC: [
|
|
15
|
+
'eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
16
|
+
'eip155:43114/erc20:0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
17
|
+
],
|
|
18
|
+
jEUR: ['eip155:1/erc20:0x0f17bc9a994b87b5225cfb6a2cd4d667adb4f20b'],
|
|
19
|
+
jCHF: ['eip155:1/erc20:0x53dfea0a8cc2a2a2e425e1c174bc162999723ea0'],
|
|
20
|
+
jGBP: ['eip155:1/erc20:0x7409856cae628f5d578b285b45669b36e7005283'],
|
|
21
|
+
WBTC: ['eip155:1/erc20:0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'],
|
|
22
|
+
AVAX: [constants_1.avalancheAssetId],
|
|
23
|
+
EURS: ['eip155:1/erc20:0xdb25f211ab05b1c97d595516f45794528a807ad8'],
|
|
24
|
+
EURT: ['eip155:1/erc20:0xc581b735a1688071a1746c968e0798d642ede491'],
|
|
25
|
+
agEUR: ['eip155:1/erc20:0x1a7e4e63778b4f12a199c062f3efdd288afcbce8'],
|
|
26
|
+
FRAX: [
|
|
27
|
+
'eip155:1/erc20:0x853d955acef822db058eb8505911ed77f175b99e',
|
|
28
|
+
'eip155:43114/erc20:0xd24c2ad096400b6fbcd2ad8b24e7acbc21a1da64',
|
|
29
|
+
],
|
|
30
|
+
UST: ['eip155:1/erc20:0xa693b19d2931d498c5b318df961919bb4aee87a5'],
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The following is the list of assets that Mt Pelerin supports
|
|
34
|
+
* but they're **not supported** (yet?) in ShapeShift
|
|
35
|
+
* {
|
|
36
|
+
'[xdai_mainnet]/0x0000000000000000000000000000000000000000': 'XDAI',
|
|
37
|
+
'[xdai_mainnet]/0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83': 'USDC',
|
|
38
|
+
'[xdai_mainnet]/0x4ECaBa5870353805a9F068101A40E0f32ed605C6': 'USDT',
|
|
39
|
+
'[xdai_mainnet]/0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252': 'WBTC',
|
|
40
|
+
'[xdai_mainnet]/0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1': 'WETH',
|
|
41
|
+
'[xdai_mainnet]/0x9fB1d52596c44603198fB0aee434fac3a679f702': 'jEUR',
|
|
42
|
+
'[xdai_mainnet]/0x2d5563da42b06FbBF9c67b7DC073cF6A7842239e': 'jCHF',
|
|
43
|
+
'[bsc_mainnet]/0x0000000000000000000000000000000000000000': 'BNB',
|
|
44
|
+
'[bsc_mainnet]/0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d': 'USDC',
|
|
45
|
+
'[bsc_mainnet]/0x55d398326f99059fF775485246999027B3197955': 'USDT',
|
|
46
|
+
'[bsc_mainnet]/0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c': 'BTCB',
|
|
47
|
+
'[bsc_mainnet]/0x2170ed0880ac9a755fd29b2688956bd959f933f8': 'WETH',
|
|
48
|
+
'[bsc_mainnet]/0xe9e7cea3dedca5984780bafc599bd69add087d56': 'BUSD',
|
|
49
|
+
'[bsc_mainnet]/0x23b8683Ff98F9E4781552DFE6f12Aa32814924e8': 'jEUR',
|
|
50
|
+
'[bsc_mainnet]/0x7c869b5A294b1314E985283d01C702B62224a05f': 'jCHF',
|
|
51
|
+
'[bsc_mainnet]/0x048E9b1ddF9EBbb224812372280e94Ccac443f9e': 'jGBP',
|
|
52
|
+
'[bsc_mainnet]/0x6B8b9AE0627a7622c593A1696859ca753c61A670': 'jZAR',
|
|
53
|
+
'[matic_mainnet]/0x0000000000000000000000000000000000000000': 'MATIC',
|
|
54
|
+
'[matic_mainnet]/0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174': 'USDC',
|
|
55
|
+
'[matic_mainnet]/0xc2132D05D31c914a87C6611C10748AEb04B58e8F': 'USDT',
|
|
56
|
+
'[matic_mainnet]/0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6': 'WBTC',
|
|
57
|
+
'[matic_mainnet]/0x4e3Decbb3645551B8A19f0eA1678079FCB33fB4c': 'jEUR',
|
|
58
|
+
'[matic_mainnet]/0xbD1463F02f61676d53fd183C2B19282BFF93D099': 'jCHF',
|
|
59
|
+
'[matic_mainnet]/0x767058F11800FBA6A682E73A6e79ec5eB74Fac8c': 'jGBP',
|
|
60
|
+
'[matic_mainnet]/0x8ca194A3b22077359b5732DE53373D4afC11DeE3': 'jCAD',
|
|
61
|
+
'[matic_mainnet]/0xa926db7a4CC0cb1736D5ac60495ca8Eb7214B503': 'jSGD',
|
|
62
|
+
'[matic_mainnet]/0x197E5d6CcfF265AC3E303a34Db360ee1429f5d1A': 'jSEK',
|
|
63
|
+
'[matic_mainnet]/0xCB7F1Ef7246D1497b985f7FC45A1A31F04346133': 'jAUD',
|
|
64
|
+
'[matic_mainnet]/0x8343091F2499FD4b6174A46D067A920a3b851FF9': 'jJPY',
|
|
65
|
+
'[matic_mainnet]/0x7ceb23fd6bc0add59e62ac25578270cff1b9f619': 'WETH',
|
|
66
|
+
'[matic_mainnet]/0xE111178A87A3BFf0c8d18DECBa5798827539Ae99': 'EURS',
|
|
67
|
+
'[matic_mainnet]/0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f': 'EURT',
|
|
68
|
+
'[matic_mainnet]/0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4': 'agEUR',
|
|
69
|
+
'[matic_mainnet]/0x45c32fA6DF82ead1e2EF74d17b76547EDdFaFF89': 'FRAX',
|
|
70
|
+
'[matic_mainnet]/0xa3Fa99A148fA48D14Ed51d610c367C61876997F1': 'MAI',
|
|
71
|
+
'[matic_mainnet]/0xE6469Ba6D2fD6130788E0eA9C0a0515900563b59': 'UST',
|
|
72
|
+
'[tezos_mainnet]/0x0000000000000000000000000000000000000000': 'XTZ',
|
|
73
|
+
'[tezos_mainnet]/KT1JBNFcB5tiycHNdYGYCtR3kk6JaJysUCi8': 'EURL',
|
|
74
|
+
'[arbitrum_mainnet]/0x0000000000000000000000000000000000000000': 'ETH',
|
|
75
|
+
'[arbitrum_mainnet]/0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8': 'USDC',
|
|
76
|
+
'[optimism_mainnet]/0x0000000000000000000000000000000000000000': 'ETH',
|
|
77
|
+
'[optimism_mainnet]/0x7F5c764cBc14f9669B88837ca1490cCa17c31607': 'USDC',
|
|
78
|
+
'[avalanche_mainnet]/0x9fB1d52596c44603198fB0aee434fac3a679f702': 'jEUR',
|
|
79
|
+
'[avalanche_mainnet]/0x2d5563da42b06FbBF9c67b7DC073cF6A7842239e': 'jCHF',
|
|
80
|
+
'[avalanche_mainnet]/0x5c49b268c9841AFF1Cc3B0a418ff5c3442eE3F3b': 'MAI',
|
|
81
|
+
'[avalanche_mainnet]/0xb599c3590F42f8F995ECfa0f85D2980B76862fc1': 'UST',
|
|
82
|
+
'[fantom_mainnet]/0x0000000000000000000000000000000000000000': 'FTM',
|
|
83
|
+
'[fantom_mainnet]/0x04068DA6C83AFCFA0e13ba15A6696662335D5B75': 'USDC',
|
|
84
|
+
'[fantom_mainnet]/0xdc301622e621166BD8E82f2cA0A26c13Ad0BE355': 'FRAX',
|
|
85
|
+
'[fantom_mainnet]/0xfB98B335551a418cD0737375a2ea0ded62Ea213b': 'MAI',
|
|
86
|
+
'[fantom_mainnet]/0x846e4D51d7E2043C1a87E0Ab7490B93FB940357b': 'UST',
|
|
87
|
+
'[rsk_mainnet]/0x0000000000000000000000000000000000000000': 'RBTC',
|
|
88
|
+
'[rsk_mainnet]/0x2d919f19d4892381d58edebeca66d5642cef1a1f': 'RDOC',
|
|
89
|
+
'[rsk_mainnet]/0xef213441a85df4d7acbdae0cf78004e1e486bb96': 'USDT',
|
|
90
|
+
'[rsk_mainnet]/0x2acc95758f8b5f583470ba265eb685a8f45fc9d5': 'RIF',
|
|
91
|
+
'[ethChainId]/0x89d71DfbDD6ebeCd0dfe27D55189F903169d2991': 'THDX'
|
|
92
|
+
* }
|
|
93
|
+
*/
|
|
94
|
+
const mtPelerinSymbolToAssetIds = (id) => MtPelerinSymbolToAssetIds[id];
|
|
95
|
+
exports.mtPelerinSymbolToAssetIds = mtPelerinSymbolToAssetIds;
|
|
96
|
+
const assetIdToMtPelerinSymbol = (assetId) => {
|
|
97
|
+
return Object.entries(MtPelerinSymbolToAssetIds)
|
|
98
|
+
.filter(([, assetIds]) => assetIds.includes(assetId))
|
|
99
|
+
.map(([key]) => key)[0];
|
|
100
|
+
};
|
|
101
|
+
exports.assetIdToMtPelerinSymbol = assetIdToMtPelerinSymbol;
|
|
102
|
+
/**
|
|
103
|
+
* map ChainIds to MtPelerin network,
|
|
104
|
+
* since some MtPelerin assets could be on multiple chains and their default
|
|
105
|
+
* chain won't be exactly the same as ours.
|
|
106
|
+
*
|
|
107
|
+
* https://developers.mtPelerin.com/integration-guides/options -> "net"
|
|
108
|
+
* source of truth per MtPelerin
|
|
109
|
+
*/
|
|
110
|
+
const chainIdToMtPelerinNetworkCodeMap = {
|
|
111
|
+
[constants_1.ethChainId]: 'mainnet',
|
|
112
|
+
[constants_1.btcChainId]: 'bitcoin_mainnet',
|
|
113
|
+
[constants_1.avalancheChainId]: 'avalanche_mainnet', // this is actually the C-Chain
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Convert a mtPelerin asset identifier to a MtPelerin chain identifier for use in MtPelerin HTTP URLs
|
|
117
|
+
*
|
|
118
|
+
* @param {string} assetId - an assetId string referencing a specific asset; e.g., ethAssetId
|
|
119
|
+
* @returns {string} - a MtPelerin network identifier; e.g., 'mainnet'
|
|
120
|
+
*/
|
|
121
|
+
const getMtPelerinNetFromAssetId = (assetId) => {
|
|
122
|
+
const { chainId } = (0, assetId_1.fromAssetId)(assetId);
|
|
123
|
+
return chainIdToMtPelerinNetworkCodeMap[chainId];
|
|
124
|
+
};
|
|
125
|
+
exports.getMtPelerinNetFromAssetId = getMtPelerinNetFromAssetId;
|
|
@@ -34,7 +34,7 @@ const parseOsmosisData = (data) => {
|
|
|
34
34
|
assetReference = denom.split('/')[1];
|
|
35
35
|
assetNamespace = 'ibc';
|
|
36
36
|
}
|
|
37
|
-
const chainNamespace = constants_1.CHAIN_NAMESPACE.
|
|
37
|
+
const chainNamespace = constants_1.CHAIN_NAMESPACE.CosmosSdk;
|
|
38
38
|
const chainReference = constants_1.CHAIN_REFERENCE.OsmosisMainnet;
|
|
39
39
|
const assetId = (0, assetId_1.toAssetId)({ chainNamespace, chainReference, assetNamespace, assetReference });
|
|
40
40
|
acc[assetId] = symbol;
|
|
@@ -45,7 +45,7 @@ const parseOsmosisData = (data) => {
|
|
|
45
45
|
exports.parseOsmosisData = parseOsmosisData;
|
|
46
46
|
const parseData = (d) => {
|
|
47
47
|
const osmosisMainnet = (0, chainId_1.toChainId)({
|
|
48
|
-
chainNamespace: constants_1.CHAIN_NAMESPACE.
|
|
48
|
+
chainNamespace: constants_1.CHAIN_NAMESPACE.CosmosSdk,
|
|
49
49
|
chainReference: constants_1.CHAIN_REFERENCE.OsmosisMainnet,
|
|
50
50
|
});
|
|
51
51
|
return {
|
|
@@ -36,7 +36,7 @@ const fetchData = async () => {
|
|
|
36
36
|
exports.fetchData = fetchData;
|
|
37
37
|
const parseEthData = (data) => {
|
|
38
38
|
const assetNamespace = 'erc20';
|
|
39
|
-
const chainNamespace = constants_1.CHAIN_NAMESPACE.
|
|
39
|
+
const chainNamespace = constants_1.CHAIN_NAMESPACE.Evm;
|
|
40
40
|
const chainReference = constants_1.CHAIN_REFERENCE.EthereumMainnet;
|
|
41
41
|
return data.reduce((acc, datum) => {
|
|
42
42
|
const { address } = datum;
|
|
@@ -55,7 +55,7 @@ const parseEthData = (data) => {
|
|
|
55
55
|
exports.parseEthData = parseEthData;
|
|
56
56
|
const parseData = (d) => {
|
|
57
57
|
const ethMainnet = (0, chainId_1.toChainId)({
|
|
58
|
-
chainNamespace: constants_1.CHAIN_NAMESPACE.
|
|
58
|
+
chainNamespace: constants_1.CHAIN_NAMESPACE.Evm,
|
|
59
59
|
chainReference: constants_1.CHAIN_REFERENCE.EthereumMainnet,
|
|
60
60
|
});
|
|
61
61
|
return { [ethMainnet]: (0, exports.parseEthData)(d) };
|
package/dist/constants.d.ts
CHANGED
|
@@ -17,9 +17,9 @@ export declare const avalancheChainId: ChainId;
|
|
|
17
17
|
export declare const cosmosChainId: ChainId;
|
|
18
18
|
export declare const osmosisChainId: ChainId;
|
|
19
19
|
export declare const CHAIN_NAMESPACE: {
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
20
|
+
readonly Evm: "eip155";
|
|
21
|
+
readonly Utxo: "bip122";
|
|
22
|
+
readonly CosmosSdk: "cosmos";
|
|
23
23
|
};
|
|
24
24
|
declare type ValidChainMap = {
|
|
25
25
|
[k in ChainNamespace]: ChainReference[];
|
package/dist/constants.js
CHANGED
|
@@ -18,9 +18,9 @@ exports.avalancheChainId = 'eip155:43114';
|
|
|
18
18
|
exports.cosmosChainId = 'cosmos:cosmoshub-4';
|
|
19
19
|
exports.osmosisChainId = 'cosmos:osmosis-1';
|
|
20
20
|
exports.CHAIN_NAMESPACE = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
Evm: 'eip155',
|
|
22
|
+
Utxo: 'bip122',
|
|
23
|
+
CosmosSdk: 'cosmos',
|
|
24
24
|
};
|
|
25
25
|
exports.CHAIN_REFERENCE = {
|
|
26
26
|
EthereumMainnet: '1',
|
|
@@ -41,20 +41,20 @@ exports.CHAIN_REFERENCE = {
|
|
|
41
41
|
AvalancheCChain: '43114', // https://docs.avax.network/apis/avalanchego/apis/c-chain
|
|
42
42
|
};
|
|
43
43
|
exports.VALID_CHAIN_IDS = Object.freeze({
|
|
44
|
-
[exports.CHAIN_NAMESPACE.
|
|
44
|
+
[exports.CHAIN_NAMESPACE.Utxo]: [
|
|
45
45
|
exports.CHAIN_REFERENCE.BitcoinMainnet,
|
|
46
46
|
exports.CHAIN_REFERENCE.BitcoinTestnet,
|
|
47
47
|
exports.CHAIN_REFERENCE.BitcoinCashMainnet,
|
|
48
48
|
exports.CHAIN_REFERENCE.DogecoinMainnet,
|
|
49
49
|
exports.CHAIN_REFERENCE.LitecoinMainnet,
|
|
50
50
|
],
|
|
51
|
-
[exports.CHAIN_NAMESPACE.
|
|
51
|
+
[exports.CHAIN_NAMESPACE.Evm]: [
|
|
52
52
|
exports.CHAIN_REFERENCE.EthereumMainnet,
|
|
53
53
|
exports.CHAIN_REFERENCE.EthereumRopsten,
|
|
54
54
|
exports.CHAIN_REFERENCE.EthereumRinkeby,
|
|
55
55
|
exports.CHAIN_REFERENCE.AvalancheCChain,
|
|
56
56
|
],
|
|
57
|
-
[exports.CHAIN_NAMESPACE.
|
|
57
|
+
[exports.CHAIN_NAMESPACE.CosmosSdk]: [
|
|
58
58
|
exports.CHAIN_REFERENCE.CosmosHubMainnet,
|
|
59
59
|
exports.CHAIN_REFERENCE.CosmosHubVega,
|
|
60
60
|
exports.CHAIN_REFERENCE.OsmosisMainnet,
|
|
@@ -62,9 +62,9 @@ exports.VALID_CHAIN_IDS = Object.freeze({
|
|
|
62
62
|
],
|
|
63
63
|
});
|
|
64
64
|
exports.VALID_ASSET_NAMESPACE = Object.freeze({
|
|
65
|
-
[exports.CHAIN_NAMESPACE.
|
|
66
|
-
[exports.CHAIN_NAMESPACE.
|
|
67
|
-
[exports.CHAIN_NAMESPACE.
|
|
65
|
+
[exports.CHAIN_NAMESPACE.Utxo]: ['slip44'],
|
|
66
|
+
[exports.CHAIN_NAMESPACE.Evm]: ['slip44', 'erc20', 'erc721'],
|
|
67
|
+
[exports.CHAIN_NAMESPACE.CosmosSdk]: ['cw20', 'cw721', 'ibc', 'native', 'slip44'],
|
|
68
68
|
});
|
|
69
69
|
exports.ASSET_NAMESPACE_STRINGS = [
|
|
70
70
|
'cw20',
|