@parallel-protocol/chains 0.1.1 → 0.2.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 +20 -0
- package/dist/index.cjs +61 -0
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +60 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,26 @@ ABIs are exposed under the `/abi` subpath:
|
|
|
55
55
|
import { PARALLELIZER_ABI, ERC20_ABI } from "@parallel-protocol/chains/abi";
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
## Payment tokens
|
|
59
|
+
|
|
60
|
+
`getTokenDecimals` is the single source of truth for the decimals of every
|
|
61
|
+
Parallel payment token — USDp, sUSDp, USDC and the Parallelizer backing
|
|
62
|
+
collaterals — so merchant and payer sides price amounts identically:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { getTokenDecimals, COLLATERAL_TOKENS } from "@parallel-protocol/chains";
|
|
66
|
+
|
|
67
|
+
getTokenDecimals("base", "0x76A9A0062ec…"); // 18 (USDp)
|
|
68
|
+
getTokenDecimals("base", "0x833589fCD6…"); // 6 (USDC)
|
|
69
|
+
getTokenDecimals("base", "0x820C137fa7…"); // 18 (USDS, a backing collateral)
|
|
70
|
+
getTokenDecimals("base", "0xdead…"); // undefined — outside the catalogue
|
|
71
|
+
|
|
72
|
+
COLLATERAL_TOKENS.base; // { "0x820c…": { symbol: "USDS", decimals: 18 }, … }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Values are verified on-chain and immutable per token; `undefined` lets callers
|
|
76
|
+
decide their own fallback for tokens outside the catalogue.
|
|
77
|
+
|
|
58
78
|
## Composing your RPC layer
|
|
59
79
|
|
|
60
80
|
Pass `.viem` straight to `createPublicClient` — RPC URLs are intentionally
|
package/dist/index.cjs
CHANGED
|
@@ -392,10 +392,70 @@ function getMulticall3Address(chainName) {
|
|
|
392
392
|
return cfg?.viem.contracts?.multicall3?.address;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
// src/tokens.ts
|
|
396
|
+
var USDC_BASE = USDC_CHAIN_ADDRESSES.base;
|
|
397
|
+
var USDC_AVALANCHE = USDC_CHAIN_ADDRESSES.avalanche;
|
|
398
|
+
var COLLATERAL_TOKENS = {
|
|
399
|
+
ethereum: {
|
|
400
|
+
"0xcacd6fd266af91b8aed52accc382b4e165586e29": {
|
|
401
|
+
symbol: "frxUSD",
|
|
402
|
+
decimals: 18
|
|
403
|
+
},
|
|
404
|
+
"0xcf62f905562626cfcdd2261162a51fd02fc9c5b6": {
|
|
405
|
+
symbol: "sfrxUSD",
|
|
406
|
+
decimals: 18
|
|
407
|
+
},
|
|
408
|
+
"0x4c9edd5852cd905f086c759e8383e09bff1e68b3": {
|
|
409
|
+
symbol: "USDe",
|
|
410
|
+
decimals: 18
|
|
411
|
+
},
|
|
412
|
+
"0x9d39a5de30e57443bff2a8307a4256c8797a3497": {
|
|
413
|
+
symbol: "sUSDe",
|
|
414
|
+
decimals: 18
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
base: {
|
|
418
|
+
"0x820c137fa70c8691f0e44dc420a5e53c168921dc": {
|
|
419
|
+
symbol: "USDS",
|
|
420
|
+
decimals: 18
|
|
421
|
+
},
|
|
422
|
+
"0x5875eee11cf8398102fdad704c9e96607675467a": {
|
|
423
|
+
symbol: "sUSDS",
|
|
424
|
+
decimals: 18
|
|
425
|
+
},
|
|
426
|
+
[USDC_BASE.toLowerCase()]: { symbol: "USDC", decimals: 6 }
|
|
427
|
+
},
|
|
428
|
+
avalanche: {
|
|
429
|
+
"0x9fd32fd5e32c6b95483d36c5e724c5c5250ce010": {
|
|
430
|
+
symbol: "ygamiUSDC",
|
|
431
|
+
decimals: 6
|
|
432
|
+
},
|
|
433
|
+
[USDC_AVALANCHE.toLowerCase()]: { symbol: "USDC", decimals: 6 }
|
|
434
|
+
},
|
|
435
|
+
hyperevm: {
|
|
436
|
+
"0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34": {
|
|
437
|
+
symbol: "USDe",
|
|
438
|
+
decimals: 18
|
|
439
|
+
},
|
|
440
|
+
"0x211cc4dd073734da055fbf44a2b4667d5e5fe5d2": {
|
|
441
|
+
symbol: "sUSDe",
|
|
442
|
+
decimals: 18
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
function getTokenDecimals(chainName, address) {
|
|
447
|
+
const lower = address.toLowerCase();
|
|
448
|
+
if (getUSDpAddress(chainName)?.toLowerCase() === lower) return 18;
|
|
449
|
+
if (getSUSDpAddress(chainName)?.toLowerCase() === lower) return 18;
|
|
450
|
+
if (getUSDCAddress(chainName)?.toLowerCase() === lower) return 6;
|
|
451
|
+
return COLLATERAL_TOKENS[chainName]?.[lower]?.decimals;
|
|
452
|
+
}
|
|
453
|
+
|
|
395
454
|
exports.ACTIVE_CHAINS = ACTIVE_CHAINS;
|
|
396
455
|
exports.BPT_POOL_ID = BPT_POOL_ID;
|
|
397
456
|
exports.CHAINS_STATIC = CHAINS_STATIC;
|
|
398
457
|
exports.CHAIN_NAMES = CHAIN_NAMES;
|
|
458
|
+
exports.COLLATERAL_TOKENS = COLLATERAL_TOKENS;
|
|
399
459
|
exports.ChainEnum = ChainEnum;
|
|
400
460
|
exports.PARALLELIZER_CHAINS = PARALLELIZER_CHAINS;
|
|
401
461
|
exports.PRL_ADDRESS = PRL_ADDRESS;
|
|
@@ -411,6 +471,7 @@ exports.getChainId = getChainId;
|
|
|
411
471
|
exports.getMulticall3Address = getMulticall3Address;
|
|
412
472
|
exports.getParallelizerAddress = getParallelizerAddress;
|
|
413
473
|
exports.getSUSDpAddress = getSUSDpAddress;
|
|
474
|
+
exports.getTokenDecimals = getTokenDecimals;
|
|
414
475
|
exports.getUSDCAddress = getUSDCAddress;
|
|
415
476
|
exports.getUSDpAddress = getUSDpAddress;
|
|
416
477
|
exports.isKnownChain = isKnownChain;
|
package/dist/index.d.cts
CHANGED
|
@@ -101,4 +101,21 @@ declare function isKnownChain(chainName: string): chainName is Chain;
|
|
|
101
101
|
/** Returns the canonical multicall3 address for a given chain, if available. */
|
|
102
102
|
declare function getMulticall3Address(chainName: string): Address | undefined;
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
type TokenInfo = {
|
|
105
|
+
symbol: string;
|
|
106
|
+
decimals: number;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Parallelizer backing collaterals per chain — addresses and decimals verified
|
|
110
|
+
* on-chain (`getCollateralList`). Keys are lowercase addresses. USDp and sUSDp
|
|
111
|
+
* are protocol tokens, not collaterals; they resolve through the chain catalog.
|
|
112
|
+
*/
|
|
113
|
+
declare const COLLATERAL_TOKENS: Partial<Record<Chain, Record<string, TokenInfo>>>;
|
|
114
|
+
/**
|
|
115
|
+
* Decimals of a known Parallel payment token (USDp, sUSDp, USDC or a backing
|
|
116
|
+
* collateral) by address. Returns `undefined` for tokens outside the catalog
|
|
117
|
+
* so callers can fall back explicitly.
|
|
118
|
+
*/
|
|
119
|
+
declare function getTokenDecimals(chainName: string, address: string): number | undefined;
|
|
120
|
+
|
|
121
|
+
export { ACTIVE_CHAINS, BPT_POOL_ID, CHAINS_STATIC, CHAIN_NAMES, COLLATERAL_TOKENS, type Chain, type ChainContracts, ChainEnum, type ChainStaticConfig, type ChainStatus, PARALLELIZER_CHAINS, PRL_ADDRESS, REWARD_MERKLE_DISTRIBUTOR_ADDRESS, SAVINGS_CHAINS, SPRL1_ADDRESS, SPRL1_CHAIN_ADDRESSES, SPRL2_ADDRESS, STAKING_CHAINS, USDC_CHAIN_ADDRESSES, WETH_ADDRESS, getChainId, getMulticall3Address, getParallelizerAddress, getSUSDpAddress, getTokenDecimals, getUSDCAddress, getUSDpAddress, isKnownChain, isParallelizerChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -101,4 +101,21 @@ declare function isKnownChain(chainName: string): chainName is Chain;
|
|
|
101
101
|
/** Returns the canonical multicall3 address for a given chain, if available. */
|
|
102
102
|
declare function getMulticall3Address(chainName: string): Address | undefined;
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
type TokenInfo = {
|
|
105
|
+
symbol: string;
|
|
106
|
+
decimals: number;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Parallelizer backing collaterals per chain — addresses and decimals verified
|
|
110
|
+
* on-chain (`getCollateralList`). Keys are lowercase addresses. USDp and sUSDp
|
|
111
|
+
* are protocol tokens, not collaterals; they resolve through the chain catalog.
|
|
112
|
+
*/
|
|
113
|
+
declare const COLLATERAL_TOKENS: Partial<Record<Chain, Record<string, TokenInfo>>>;
|
|
114
|
+
/**
|
|
115
|
+
* Decimals of a known Parallel payment token (USDp, sUSDp, USDC or a backing
|
|
116
|
+
* collateral) by address. Returns `undefined` for tokens outside the catalog
|
|
117
|
+
* so callers can fall back explicitly.
|
|
118
|
+
*/
|
|
119
|
+
declare function getTokenDecimals(chainName: string, address: string): number | undefined;
|
|
120
|
+
|
|
121
|
+
export { ACTIVE_CHAINS, BPT_POOL_ID, CHAINS_STATIC, CHAIN_NAMES, COLLATERAL_TOKENS, type Chain, type ChainContracts, ChainEnum, type ChainStaticConfig, type ChainStatus, PARALLELIZER_CHAINS, PRL_ADDRESS, REWARD_MERKLE_DISTRIBUTOR_ADDRESS, SAVINGS_CHAINS, SPRL1_ADDRESS, SPRL1_CHAIN_ADDRESSES, SPRL2_ADDRESS, STAKING_CHAINS, USDC_CHAIN_ADDRESSES, WETH_ADDRESS, getChainId, getMulticall3Address, getParallelizerAddress, getSUSDpAddress, getTokenDecimals, getUSDCAddress, getUSDpAddress, isKnownChain, isParallelizerChain };
|
package/dist/index.js
CHANGED
|
@@ -390,4 +390,63 @@ function getMulticall3Address(chainName) {
|
|
|
390
390
|
return cfg?.viem.contracts?.multicall3?.address;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
|
|
393
|
+
// src/tokens.ts
|
|
394
|
+
var USDC_BASE = USDC_CHAIN_ADDRESSES.base;
|
|
395
|
+
var USDC_AVALANCHE = USDC_CHAIN_ADDRESSES.avalanche;
|
|
396
|
+
var COLLATERAL_TOKENS = {
|
|
397
|
+
ethereum: {
|
|
398
|
+
"0xcacd6fd266af91b8aed52accc382b4e165586e29": {
|
|
399
|
+
symbol: "frxUSD",
|
|
400
|
+
decimals: 18
|
|
401
|
+
},
|
|
402
|
+
"0xcf62f905562626cfcdd2261162a51fd02fc9c5b6": {
|
|
403
|
+
symbol: "sfrxUSD",
|
|
404
|
+
decimals: 18
|
|
405
|
+
},
|
|
406
|
+
"0x4c9edd5852cd905f086c759e8383e09bff1e68b3": {
|
|
407
|
+
symbol: "USDe",
|
|
408
|
+
decimals: 18
|
|
409
|
+
},
|
|
410
|
+
"0x9d39a5de30e57443bff2a8307a4256c8797a3497": {
|
|
411
|
+
symbol: "sUSDe",
|
|
412
|
+
decimals: 18
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
base: {
|
|
416
|
+
"0x820c137fa70c8691f0e44dc420a5e53c168921dc": {
|
|
417
|
+
symbol: "USDS",
|
|
418
|
+
decimals: 18
|
|
419
|
+
},
|
|
420
|
+
"0x5875eee11cf8398102fdad704c9e96607675467a": {
|
|
421
|
+
symbol: "sUSDS",
|
|
422
|
+
decimals: 18
|
|
423
|
+
},
|
|
424
|
+
[USDC_BASE.toLowerCase()]: { symbol: "USDC", decimals: 6 }
|
|
425
|
+
},
|
|
426
|
+
avalanche: {
|
|
427
|
+
"0x9fd32fd5e32c6b95483d36c5e724c5c5250ce010": {
|
|
428
|
+
symbol: "ygamiUSDC",
|
|
429
|
+
decimals: 6
|
|
430
|
+
},
|
|
431
|
+
[USDC_AVALANCHE.toLowerCase()]: { symbol: "USDC", decimals: 6 }
|
|
432
|
+
},
|
|
433
|
+
hyperevm: {
|
|
434
|
+
"0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34": {
|
|
435
|
+
symbol: "USDe",
|
|
436
|
+
decimals: 18
|
|
437
|
+
},
|
|
438
|
+
"0x211cc4dd073734da055fbf44a2b4667d5e5fe5d2": {
|
|
439
|
+
symbol: "sUSDe",
|
|
440
|
+
decimals: 18
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
function getTokenDecimals(chainName, address) {
|
|
445
|
+
const lower = address.toLowerCase();
|
|
446
|
+
if (getUSDpAddress(chainName)?.toLowerCase() === lower) return 18;
|
|
447
|
+
if (getSUSDpAddress(chainName)?.toLowerCase() === lower) return 18;
|
|
448
|
+
if (getUSDCAddress(chainName)?.toLowerCase() === lower) return 6;
|
|
449
|
+
return COLLATERAL_TOKENS[chainName]?.[lower]?.decimals;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export { ACTIVE_CHAINS, BPT_POOL_ID, CHAINS_STATIC, CHAIN_NAMES, COLLATERAL_TOKENS, ChainEnum, PARALLELIZER_CHAINS, PRL_ADDRESS, REWARD_MERKLE_DISTRIBUTOR_ADDRESS, SAVINGS_CHAINS, SPRL1_ADDRESS, SPRL1_CHAIN_ADDRESSES, SPRL2_ADDRESS, STAKING_CHAINS, USDC_CHAIN_ADDRESSES, WETH_ADDRESS, getChainId, getMulticall3Address, getParallelizerAddress, getSUSDpAddress, getTokenDecimals, getUSDCAddress, getUSDpAddress, isKnownChain, isParallelizerChain };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parallel-protocol/chains",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Parallel Protocol on-chain catalogue — chain ids, contract addresses, viem-typed ABIs",
|
|
5
5
|
"author": "Parallel Protocol <contact@parallel.best>",
|
|
6
6
|
"repository": "github:parallel-protocol/sdk-merchant",
|