@1delta/data-sdk 0.0.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.
@@ -0,0 +1 @@
1
+ export * from './lending';
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ // src/lending.ts
4
+ var GLOBAL_DATA_KEY = "__1delta_data_registry__";
5
+ function getGlobalData() {
6
+ return globalThis[GLOBAL_DATA_KEY];
7
+ }
8
+ function initializeData({
9
+ aaveTokensOverride,
10
+ aavePoolsOverride,
11
+ compoundV3PoolsOverride,
12
+ compoundV3BaseDataOverride,
13
+ morphoPoolsOverride,
14
+ compoundV2TokensOverride,
15
+ compoundV2PoolsOverride,
16
+ initConfigOverride
17
+ }) {
18
+ const data = getGlobalData();
19
+ if (aaveTokensOverride) data.aaveTokens = aaveTokensOverride;
20
+ if (aavePoolsOverride) data.aavePools = aavePoolsOverride;
21
+ if (compoundV3PoolsOverride) data.compoundV3Pools = compoundV3PoolsOverride;
22
+ if (morphoPoolsOverride) data.morphoPools = morphoPoolsOverride;
23
+ if (compoundV3BaseDataOverride) data.compoundV3BaseData = compoundV3BaseDataOverride;
24
+ if (compoundV2TokensOverride) data.compoundV2Tokens = compoundV2TokensOverride;
25
+ if (compoundV2PoolsOverride) data.compoundV2Pools = compoundV2PoolsOverride;
26
+ if (initConfigOverride) data.initConfig = initConfigOverride;
27
+ }
28
+ var aaveTokens = () => getGlobalData().aaveTokens;
29
+ var aavePools = () => getGlobalData().aavePools;
30
+ var compoundV3Pools = () => getGlobalData().compoundV3Pools;
31
+ var morphoPools = () => getGlobalData().morphoPools;
32
+ var compoundV3BaseData = () => getGlobalData().compoundV3BaseData;
33
+ var compoundV2Pools = () => getGlobalData().compoundV2Pools;
34
+ var compoundV2Tokens = () => getGlobalData().compoundV2Tokens;
35
+ var initConfig = () => getGlobalData().initConfig;
36
+
37
+ exports.aavePools = aavePools;
38
+ exports.aaveTokens = aaveTokens;
39
+ exports.compoundV2Pools = compoundV2Pools;
40
+ exports.compoundV2Tokens = compoundV2Tokens;
41
+ exports.compoundV3BaseData = compoundV3BaseData;
42
+ exports.compoundV3Pools = compoundV3Pools;
43
+ exports.initConfig = initConfig;
44
+ exports.initializeData = initializeData;
45
+ exports.morphoPools = morphoPools;
package/dist/index.mjs ADDED
@@ -0,0 +1,35 @@
1
+ // src/lending.ts
2
+ var GLOBAL_DATA_KEY = "__1delta_data_registry__";
3
+ function getGlobalData() {
4
+ return globalThis[GLOBAL_DATA_KEY];
5
+ }
6
+ function initializeData({
7
+ aaveTokensOverride,
8
+ aavePoolsOverride,
9
+ compoundV3PoolsOverride,
10
+ compoundV3BaseDataOverride,
11
+ morphoPoolsOverride,
12
+ compoundV2TokensOverride,
13
+ compoundV2PoolsOverride,
14
+ initConfigOverride
15
+ }) {
16
+ const data = getGlobalData();
17
+ if (aaveTokensOverride) data.aaveTokens = aaveTokensOverride;
18
+ if (aavePoolsOverride) data.aavePools = aavePoolsOverride;
19
+ if (compoundV3PoolsOverride) data.compoundV3Pools = compoundV3PoolsOverride;
20
+ if (morphoPoolsOverride) data.morphoPools = morphoPoolsOverride;
21
+ if (compoundV3BaseDataOverride) data.compoundV3BaseData = compoundV3BaseDataOverride;
22
+ if (compoundV2TokensOverride) data.compoundV2Tokens = compoundV2TokensOverride;
23
+ if (compoundV2PoolsOverride) data.compoundV2Pools = compoundV2PoolsOverride;
24
+ if (initConfigOverride) data.initConfig = initConfigOverride;
25
+ }
26
+ var aaveTokens = () => getGlobalData().aaveTokens;
27
+ var aavePools = () => getGlobalData().aavePools;
28
+ var compoundV3Pools = () => getGlobalData().compoundV3Pools;
29
+ var morphoPools = () => getGlobalData().morphoPools;
30
+ var compoundV3BaseData = () => getGlobalData().compoundV3BaseData;
31
+ var compoundV2Pools = () => getGlobalData().compoundV2Pools;
32
+ var compoundV2Tokens = () => getGlobalData().compoundV2Tokens;
33
+ var initConfig = () => getGlobalData().initConfig;
34
+
35
+ export { aavePools, aaveTokens, compoundV2Pools, compoundV2Tokens, compoundV3BaseData, compoundV3Pools, initConfig, initializeData, morphoPools };
@@ -0,0 +1,94 @@
1
+ type AaveTokensType = {
2
+ [fork: string]: {
3
+ [chainId: string]: {
4
+ [underlying: string]: {
5
+ aToken: string;
6
+ sToken: string;
7
+ vToken: string;
8
+ };
9
+ };
10
+ };
11
+ };
12
+ type AavePoolsType = {
13
+ [fork: string]: {
14
+ [chainId: string]: {
15
+ pool: string;
16
+ protocolDataProvider: string;
17
+ };
18
+ };
19
+ };
20
+ type CompoundV3PoolsType = {
21
+ [chainId: string]: {
22
+ [comet: string]: string;
23
+ };
24
+ };
25
+ type MorphoPoolsType = {
26
+ [fork: string]: {
27
+ [chainId: string]: string;
28
+ };
29
+ };
30
+ type CompoundV3BaseDataType = {
31
+ [lender: string]: {
32
+ [chainId: string]: {
33
+ baseAsset: string;
34
+ baseBorrowMin: bigint;
35
+ };
36
+ };
37
+ };
38
+ type CompoundV2PoolsType = {
39
+ [fork: string]: {
40
+ [chainId: string]: string;
41
+ };
42
+ };
43
+ type CompoundV2TokensType = {
44
+ [lender: string]: {
45
+ [chainId: string]: {
46
+ [address: string]: string;
47
+ };
48
+ };
49
+ };
50
+ type ModeEntry = {
51
+ pool: string;
52
+ underlying: string;
53
+ };
54
+ type PoolDatas = {
55
+ [pool: string]: {
56
+ underlying: string;
57
+ modes: number[];
58
+ };
59
+ };
60
+ type ModeData = {
61
+ [mode: number]: ModeEntry[];
62
+ };
63
+ type InitConfigType = {
64
+ [fork: string]: {
65
+ [chainid: string]: {
66
+ poolsToUnderlying: {
67
+ [poolAddress: string]: string;
68
+ };
69
+ modeData: ModeData;
70
+ poolData: PoolDatas;
71
+ reserves: string[];
72
+ };
73
+ };
74
+ };
75
+ /** Override datas used in the SDK - works across all module instances */
76
+ export declare function initializeData({ aaveTokensOverride, aavePoolsOverride, compoundV3PoolsOverride, compoundV3BaseDataOverride, morphoPoolsOverride, compoundV2TokensOverride, compoundV2PoolsOverride, initConfigOverride, }: {
77
+ aaveTokensOverride?: AaveTokensType;
78
+ aavePoolsOverride?: AavePoolsType;
79
+ compoundV3PoolsOverride?: CompoundV3PoolsType;
80
+ compoundV3BaseDataOverride?: CompoundV3BaseDataType;
81
+ morphoPoolsOverride?: MorphoPoolsType;
82
+ compoundV2TokensOverride?: CompoundV2TokensType;
83
+ compoundV2PoolsOverride?: CompoundV2PoolsType;
84
+ initConfigOverride?: InitConfigType;
85
+ }): void;
86
+ export declare const aaveTokens: () => AaveTokensType;
87
+ export declare const aavePools: () => AavePoolsType;
88
+ export declare const compoundV3Pools: () => CompoundV3PoolsType;
89
+ export declare const morphoPools: () => MorphoPoolsType;
90
+ export declare const compoundV3BaseData: () => CompoundV3BaseDataType;
91
+ export declare const compoundV2Pools: () => CompoundV2PoolsType;
92
+ export declare const compoundV2Tokens: () => CompoundV2TokensType;
93
+ export declare const initConfig: () => InitConfigType;
94
+ export {};
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@1delta/data-sdk",
3
+ "license": "MIT",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "version": "0.0.1",
8
+ "description": "Hold and initialize lending protocol data",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "keywords": [
13
+ "dex"
14
+ ],
15
+ "sideEffects": false,
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "module": "dist/index.mjs",
19
+ "dependencies": {},
20
+ "devDependencies": {
21
+ "tsup": "^8.5.0",
22
+ "typescript": "^5.8.3"
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "prettier": {
28
+ "printWidth": 120,
29
+ "semi": false,
30
+ "singleQuote": true
31
+ },
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.mjs",
37
+ "require": "./dist/index.js"
38
+ }
39
+ },
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "dev": "tsup --watch",
43
+ "test": "vitest --run",
44
+ "coverage": "vitest run --coverage",
45
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
46
+ }
47
+ }