impermax-sdk 1.2.102 → 1.2.104
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/lib/config/amms.d.ts +3 -1
- package/lib/config/amms.js +4 -1
- package/lib/config/farms.d.ts +3 -1
- package/lib/config/farms.js +3 -0
- package/lib/config/subgraphs.d.ts +1 -1
- package/lib/config/subgraphs.js +40 -28
- package/lib/offchain/configManager/offchainConfigManagerInitializer.js +3 -24
- package/lib/offchain/offchain.d.ts +2 -0
- package/lib/offchain/offchain.js +2 -0
- package/lib/offchain/offchainEndpointManager.d.ts +25 -0
- package/lib/offchain/offchainEndpointManager.js +125 -0
- package/lib/offchain/offchainInitializer.js +61 -50
- package/lib/offchain/queries/apis/ponder/index.d.ts +14 -0
- package/lib/offchain/queries/apis/ponder/index.js +278 -0
- package/lib/offchain/queries/apis/thegraph/index.d.ts +19 -0
- package/lib/offchain/queries/apis/thegraph/index.js +349 -0
- package/lib/offchain/queries/index.d.ts +16 -0
- package/lib/offchain/queries/index.js +44 -0
- package/lib/offchain/queries/interfaces/query-builder.d.ts +19 -0
- package/lib/offchain/queries/interfaces/query-builder.js +2 -0
- package/lib/offchain/queries/interfaces/transformers.d.ts +0 -0
- package/lib/offchain/queries/interfaces/transformers.js +9 -0
- package/package.json +1 -1
package/lib/config/amms.d.ts
CHANGED
|
@@ -44,7 +44,8 @@ export declare enum Amms {
|
|
|
44
44
|
scale = "scale",
|
|
45
45
|
equalizer = "equalizer",
|
|
46
46
|
wigoswap = "wigoswap",
|
|
47
|
-
velodrome = "velodrome"
|
|
47
|
+
velodrome = "velodrome",
|
|
48
|
+
alien = "alien"
|
|
48
49
|
}
|
|
49
50
|
export declare const hrAmms: {
|
|
50
51
|
uniswap: string;
|
|
@@ -92,6 +93,7 @@ export declare const hrAmms: {
|
|
|
92
93
|
equalizer: string;
|
|
93
94
|
wigoswap: string;
|
|
94
95
|
velodrome: string;
|
|
96
|
+
alien: string;
|
|
95
97
|
};
|
|
96
98
|
export declare const AMM_FACTORY: AmmIndex;
|
|
97
99
|
export declare function getAmmByFactory(network: Networks, address: Address): Amms | null;
|
package/lib/config/amms.js
CHANGED
|
@@ -49,6 +49,7 @@ var Amms;
|
|
|
49
49
|
Amms["equalizer"] = "equalizer";
|
|
50
50
|
Amms["wigoswap"] = "wigoswap";
|
|
51
51
|
Amms["velodrome"] = "velodrome";
|
|
52
|
+
Amms["alien"] = "alien";
|
|
52
53
|
})(Amms = exports.Amms || (exports.Amms = {}));
|
|
53
54
|
exports.hrAmms = {
|
|
54
55
|
[Amms.uniswap]: 'Uniswap',
|
|
@@ -96,6 +97,7 @@ exports.hrAmms = {
|
|
|
96
97
|
[Amms.equalizer]: 'Equalizer',
|
|
97
98
|
[Amms.wigoswap]: 'Wigoswap',
|
|
98
99
|
[Amms.velodrome]: 'Velodrome',
|
|
100
|
+
[Amms.alien]: 'AlienBase',
|
|
99
101
|
};
|
|
100
102
|
exports.AMM_FACTORY = {
|
|
101
103
|
[types_1.Networks.Ropsten]: {
|
|
@@ -170,7 +172,8 @@ exports.AMM_FACTORY = {
|
|
|
170
172
|
[Amms.aeroStable]: '0x8f50a6d5ea6715f878E2984569975e8875eeBafB',
|
|
171
173
|
[Amms.aeroStable1]: '0x9111b8D7Cc1a676A70015BEA3A3a9968A44C52c3',
|
|
172
174
|
[Amms.scale]: '0xEd8db60aCc29e14bC867a497D94ca6e3CeB5eC04',
|
|
173
|
-
[Amms.uniswap]: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6'
|
|
175
|
+
[Amms.uniswap]: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
|
|
176
|
+
[Amms.alien]: '0x3E84D913803b02A4a7f027165E8cA42C14C0FdE7'
|
|
174
177
|
},
|
|
175
178
|
[types_1.Networks.Scroll]: {
|
|
176
179
|
[Amms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
package/lib/config/farms.d.ts
CHANGED
|
@@ -48,7 +48,8 @@ export declare enum Farms {
|
|
|
48
48
|
tokan = "tokan",
|
|
49
49
|
tokan1 = "tokan1",
|
|
50
50
|
tokanStable = "tokanStable",
|
|
51
|
-
velodrome = "velodrome"
|
|
51
|
+
velodrome = "velodrome",
|
|
52
|
+
alien = "alien"
|
|
52
53
|
}
|
|
53
54
|
export declare const hrFarms: {
|
|
54
55
|
quickswapOld: string;
|
|
@@ -97,6 +98,7 @@ export declare const hrFarms: {
|
|
|
97
98
|
tokan1: string;
|
|
98
99
|
tokanStable: string;
|
|
99
100
|
velodrome: string;
|
|
101
|
+
alien: string;
|
|
100
102
|
};
|
|
101
103
|
export type FarmIndex = {
|
|
102
104
|
[key in Networks]: {
|
package/lib/config/farms.js
CHANGED
|
@@ -53,6 +53,7 @@ var Farms;
|
|
|
53
53
|
Farms["tokan1"] = "tokan1";
|
|
54
54
|
Farms["tokanStable"] = "tokanStable";
|
|
55
55
|
Farms["velodrome"] = "velodrome";
|
|
56
|
+
Farms["alien"] = "alien";
|
|
56
57
|
})(Farms = exports.Farms || (exports.Farms = {}));
|
|
57
58
|
exports.hrFarms = {
|
|
58
59
|
[Farms.quickswapOld]: 'QuickSwap',
|
|
@@ -101,6 +102,7 @@ exports.hrFarms = {
|
|
|
101
102
|
[Farms.tokan1]: 'Tokan',
|
|
102
103
|
[Farms.tokanStable]: 'Tokan Stable',
|
|
103
104
|
[Farms.velodrome]: 'Velodrome',
|
|
105
|
+
[Farms.alien]: 'AlienBase',
|
|
104
106
|
};
|
|
105
107
|
exports.STAKED_LP_FACTORY = {
|
|
106
108
|
[types_1.Networks.Ropsten]: {},
|
|
@@ -171,6 +173,7 @@ exports.STAKED_LP_FACTORY = {
|
|
|
171
173
|
[types_1.Networks.Moonbeam]: {},
|
|
172
174
|
[types_1.Networks.Sxnetwork]: {},
|
|
173
175
|
[types_1.Networks.Base]: {
|
|
176
|
+
[Farms.alien]: '0xA33366eeb5850535ed7cb52d4f631B19315fbc63',
|
|
174
177
|
[Farms.aerodrome]: '0x2a32215Ba106039f5A96b6366338BDb9FB0b62E8',
|
|
175
178
|
[Farms.aeroStable]: '0x8f50a6d5ea6715f878E2984569975e8875eeBafB',
|
|
176
179
|
[Farms.aeroStable1]: '0x9111b8D7Cc1a676A70015BEA3A3a9968A44C52c3',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, NetworkFactoryIndex, NetworkIndex } from './types';
|
|
2
|
-
export declare const IMPERMAX_SUBGRAPH_URL: NetworkFactoryIndex<Address>;
|
|
2
|
+
export declare const IMPERMAX_SUBGRAPH_URL: NetworkFactoryIndex<Address[]>;
|
|
3
3
|
export declare const IMPERMAX_CHEF_SUBGRAPH_URL: NetworkIndex<string>;
|
|
4
4
|
export declare const LENDING_VAULT_SUBGRAPH_URL: NetworkIndex<string>;
|
|
5
5
|
export declare const BLOCKS_SUBGRAPH_URL: NetworkIndex<string>;
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -5,65 +5,77 @@ const types_1 = require("./types");
|
|
|
5
5
|
exports.IMPERMAX_SUBGRAPH_URL = {
|
|
6
6
|
[types_1.Networks.Ropsten]: {},
|
|
7
7
|
[types_1.Networks.Mainnet]: {
|
|
8
|
-
[types_1.Factory.V2V1]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/Dn5WZv53V1K8LrKqqYn29hhuhpwfuFfmsrsTqMgFjrD3'
|
|
8
|
+
[types_1.Factory.V2V1]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/Dn5WZv53V1K8LrKqqYn29hhuhpwfuFfmsrsTqMgFjrD3']
|
|
9
9
|
},
|
|
10
10
|
[types_1.Networks.Polygon]: {
|
|
11
|
-
[types_1.Factory.V2V1_1]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/F3BfecWo2by5QKrwhkXwuXjyLZnQqJ1wqoejwe67KuyG',
|
|
12
|
-
[types_1.Factory.V2V2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/5JbuAaWwyRm78yWpRCJJS217hXXft59g9MbsjTTZnYQa',
|
|
13
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/Giwg5N4SCehmUzNwXtAQZnZvUuTjcp7cr3nzUZosRDFU',
|
|
14
|
-
[types_1.Factory.SOL_STABLE]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/EWckMdMiZeDSGHxq2V8gZBDF549Xjr9iKkPvisqckF11',
|
|
11
|
+
[types_1.Factory.V2V1_1]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/F3BfecWo2by5QKrwhkXwuXjyLZnQqJ1wqoejwe67KuyG'],
|
|
12
|
+
[types_1.Factory.V2V2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/5JbuAaWwyRm78yWpRCJJS217hXXft59g9MbsjTTZnYQa'],
|
|
13
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/Giwg5N4SCehmUzNwXtAQZnZvUuTjcp7cr3nzUZosRDFU'],
|
|
14
|
+
[types_1.Factory.SOL_STABLE]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/EWckMdMiZeDSGHxq2V8gZBDF549Xjr9iKkPvisqckF11'],
|
|
15
15
|
},
|
|
16
16
|
[types_1.Networks.Arbitrum]: {
|
|
17
|
-
[types_1.Factory.V2V1_1]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/3PMyaq269mDMwhJ7E285RYD1r43x996b6xZmJSCGvtkm',
|
|
18
|
-
[types_1.Factory.V2V2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/BkMRb8mR5zgCbjFSgau6s27pnANhR6k64RGVKUbWaZdY',
|
|
19
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/AdLbcSfG6JnpZ7RDdHNHq3bJ21waGnRi7AJ5x3YFGYFo',
|
|
17
|
+
[types_1.Factory.V2V1_1]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/3PMyaq269mDMwhJ7E285RYD1r43x996b6xZmJSCGvtkm'],
|
|
18
|
+
[types_1.Factory.V2V2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/BkMRb8mR5zgCbjFSgau6s27pnANhR6k64RGVKUbWaZdY'],
|
|
19
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/AdLbcSfG6JnpZ7RDdHNHq3bJ21waGnRi7AJ5x3YFGYFo'],
|
|
20
20
|
},
|
|
21
21
|
[types_1.Networks.Avalanche]: {
|
|
22
|
-
[types_1.Factory.V2V1_2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/HXhHppWXhFqgLfdmTahFj2x7F5Xq8BwADxGY3nbCUAwr',
|
|
23
|
-
[types_1.Factory.V2V2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8Gz5ZGyRkSA7WBrSteeyez39AgZQsoEbtXe8GtHD7JMQ',
|
|
24
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/78e6cZp11r2coLx8YYo5y4AqzEhQXYT6sw3Bg5Tiy5XU',
|
|
22
|
+
[types_1.Factory.V2V1_2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/HXhHppWXhFqgLfdmTahFj2x7F5Xq8BwADxGY3nbCUAwr'],
|
|
23
|
+
[types_1.Factory.V2V2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8Gz5ZGyRkSA7WBrSteeyez39AgZQsoEbtXe8GtHD7JMQ'],
|
|
24
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/78e6cZp11r2coLx8YYo5y4AqzEhQXYT6sw3Bg5Tiy5XU'],
|
|
25
25
|
},
|
|
26
26
|
[types_1.Networks.Mantle]: {
|
|
27
|
-
[types_1.Factory.V2V2]: 'https://subgraph-api.mantle.xyz/subgraphs/name/impermax-finance/impermax-mantle-v2'
|
|
27
|
+
[types_1.Factory.V2V2]: ['https://subgraph-api.mantle.xyz/subgraphs/name/impermax-finance/impermax-mantle-v2']
|
|
28
28
|
},
|
|
29
29
|
[types_1.Networks.Moonriver]: {
|
|
30
|
-
[types_1.Factory.V2V1_2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/6NqkDBwiybbB3BjErF6QGGYJCqzyhVFKpNYHQTN2j8Jn'
|
|
30
|
+
[types_1.Factory.V2V1_2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/6NqkDBwiybbB3BjErF6QGGYJCqzyhVFKpNYHQTN2j8Jn']
|
|
31
31
|
},
|
|
32
32
|
[types_1.Networks.Aurora]: {},
|
|
33
33
|
[types_1.Networks.Cronos]: {},
|
|
34
34
|
[types_1.Networks.Fantom]: {
|
|
35
|
-
[types_1.Factory.SOLV1_2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8vssJypWas5oenzsjjQq1yLqMe7FRt2evcqZdzCNEWt7',
|
|
36
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/DJ2bTPinDji7Kwev3WjyfxRo487tJHiEEMEo8kmTMT8F',
|
|
37
|
-
[types_1.Factory.V2V2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/DPk9E2c9fLKF8N6rN3jcyvSrEq4VEgjdeeJcnaEKAngG'
|
|
35
|
+
[types_1.Factory.SOLV1_2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8vssJypWas5oenzsjjQq1yLqMe7FRt2evcqZdzCNEWt7'],
|
|
36
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/DJ2bTPinDji7Kwev3WjyfxRo487tJHiEEMEo8kmTMT8F'],
|
|
37
|
+
[types_1.Factory.V2V2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/DPk9E2c9fLKF8N6rN3jcyvSrEq4VEgjdeeJcnaEKAngG']
|
|
38
38
|
},
|
|
39
39
|
[types_1.Networks.Canto]: {
|
|
40
|
-
[types_1.Factory.SOLV2]: 'https://api.impermax.finance/subgraphs/name/impermax-finance/impermax-canto-solv2',
|
|
40
|
+
[types_1.Factory.SOLV2]: ['https://api.impermax.finance/subgraphs/name/impermax-finance/impermax-canto-solv2'],
|
|
41
41
|
},
|
|
42
42
|
[types_1.Networks.ZksyncEra]: {
|
|
43
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8YSS88X8ChDw1QvuAMtxjezSXNiYer9k9d3Uu8XFLHzX',
|
|
43
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/8YSS88X8ChDw1QvuAMtxjezSXNiYer9k9d3Uu8XFLHzX'],
|
|
44
44
|
},
|
|
45
45
|
[types_1.Networks.Harmony]: {},
|
|
46
46
|
[types_1.Networks.Moonbeam]: {},
|
|
47
47
|
[types_1.Networks.Sxnetwork]: {},
|
|
48
48
|
[types_1.Networks.Blast]: {
|
|
49
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/4FDikpVjE2XnDJ5QcpQ1YJXWcUDiAgE7x8ErtsHh33UB',
|
|
50
|
-
[types_1.Factory.V2V2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/6xkrXFPJ4wqh9cy9ayP19WGr2wZVSMP3FniMjcW2LUG4'
|
|
49
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/4FDikpVjE2XnDJ5QcpQ1YJXWcUDiAgE7x8ErtsHh33UB'],
|
|
50
|
+
[types_1.Factory.V2V2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/6xkrXFPJ4wqh9cy9ayP19WGr2wZVSMP3FniMjcW2LUG4']
|
|
51
51
|
},
|
|
52
52
|
[types_1.Networks.Base]: {
|
|
53
|
-
[types_1.Factory.SOLV2]:
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
[types_1.Factory.SOLV2]: [
|
|
54
|
+
'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/EjB7Dsb7WnfFf1NPPr5rbGnGmk2Jqs42nWPVHjv9997u',
|
|
55
|
+
'https://base-start-production.up.railway.app/'
|
|
56
|
+
],
|
|
57
|
+
[types_1.Factory.SOL_STABLE]: [
|
|
58
|
+
'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/9wN7xinUXf8RP8dbwpkzSmCNQKfz31FDpvPEvTQyT8SL',
|
|
59
|
+
'https://base-start-production.up.railway.app/'
|
|
60
|
+
],
|
|
61
|
+
[types_1.Factory.V2V2]: [
|
|
62
|
+
'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/B7xsBeef3FohKaFPcsAsviyLKaWXTqcSELjAsPj2B7iW',
|
|
63
|
+
'https://base-start-production.up.railway.app/'
|
|
64
|
+
],
|
|
56
65
|
},
|
|
57
66
|
[types_1.Networks.Scroll]: {
|
|
58
|
-
[types_1.Factory.SOLV2]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/9HL6kLRt3AbQsprTvk7KZdaHunJ5GGsLdYWd27nNfCFC',
|
|
59
|
-
[types_1.Factory.SOL_STABLE]: 'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/C42ymmkDArE1T5wdYKwao6mntqNSjP2E34TeGusiF3sk'
|
|
67
|
+
[types_1.Factory.SOLV2]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/9HL6kLRt3AbQsprTvk7KZdaHunJ5GGsLdYWd27nNfCFC'],
|
|
68
|
+
[types_1.Factory.SOL_STABLE]: ['https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/C42ymmkDArE1T5wdYKwao6mntqNSjP2E34TeGusiF3sk']
|
|
60
69
|
},
|
|
61
70
|
[types_1.Networks.Optimism]: {
|
|
62
|
-
[types_1.Factory.SOLV2]:
|
|
71
|
+
[types_1.Factory.SOLV2]: [
|
|
72
|
+
'https://gateway.thegraph.com/api/1350441d268f171aeb0934412dfadf3b/subgraphs/id/74C2pMzH3wNKf38PNheGZfSiY4FzmJoKiGtHLYa7oD2s',
|
|
73
|
+
'https://optimism-factory-production.up.railway.app/'
|
|
74
|
+
]
|
|
63
75
|
},
|
|
64
76
|
[types_1.Networks.Real]: {
|
|
65
|
-
[types_1.Factory.SOL_STABLE]: 'https://api.goldsky.com/api/public/project_cm2d5q4l4w31601vz4swb3vmi/subgraphs/impermax-finance/impermax-real-v2-stable/gn',
|
|
66
|
-
[types_1.Factory.SOLV2]: 'https://api.goldsky.com/api/public/project_cm2rhb30ot9wu01to8c9h9e37/subgraphs/impermax-real-solv2/3.0/gn'
|
|
77
|
+
[types_1.Factory.SOL_STABLE]: ['https://api.goldsky.com/api/public/project_cm2d5q4l4w31601vz4swb3vmi/subgraphs/impermax-finance/impermax-real-v2-stable/gn'],
|
|
78
|
+
[types_1.Factory.SOLV2]: ['https://api.goldsky.com/api/public/project_cm2rhb30ot9wu01to8c9h9e37/subgraphs/impermax-real-solv2/3.0/gn']
|
|
67
79
|
},
|
|
68
80
|
};
|
|
69
81
|
exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
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
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -33,11 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
10
|
};
|
|
34
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
12
|
exports.getProposalData = exports.getProposalsMetadata = exports.fetchProposalData = exports.fetchProposalsMetadata = void 0;
|
|
36
|
-
const
|
|
13
|
+
const queries_1 = require("../queries");
|
|
37
14
|
const subgraphs_1 = require("../../config/subgraphs");
|
|
38
15
|
function fetchProposalsMetadata(rangeBegin, rangeLength, descending) {
|
|
39
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
17
|
const subgraph = subgraphs_1.CONFIG_MANAGER_SUBGRAPH_URL[this.getOffchain().network];
|
|
18
|
+
const query = queries_1.QueryBuilderFactory.getQuery(subgraph);
|
|
41
19
|
const result = yield this.getOffchain().apolloFetcher(subgraph, query.proposalsMetaQuery(rangeBegin, rangeLength, descending));
|
|
42
20
|
return result.data.proposals;
|
|
43
21
|
});
|
|
@@ -46,6 +24,7 @@ exports.fetchProposalsMetadata = fetchProposalsMetadata;
|
|
|
46
24
|
function fetchProposalData(id) {
|
|
47
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
26
|
const subgraph = subgraphs_1.CONFIG_MANAGER_SUBGRAPH_URL[this.getOffchain().network];
|
|
27
|
+
const query = queries_1.QueryBuilderFactory.getQuery(subgraph);
|
|
49
28
|
const result = yield this.getOffchain().apolloFetcher(subgraph, query.proposalQuery(id));
|
|
50
29
|
return result.data.proposal;
|
|
51
30
|
});
|
|
@@ -4,6 +4,7 @@ import OffchainPriceHelper from "./offchainPriceHelper";
|
|
|
4
4
|
import OffchainAPRHelper from "./offchainAPRHelper";
|
|
5
5
|
import OffchainSolidexHelper from "./offchainSolidexHelper";
|
|
6
6
|
import OffchainAccount from "./account";
|
|
7
|
+
import OffchainEndpointManager from './offchainEndpointManager';
|
|
7
8
|
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks, WhitelistState } from '../config/types';
|
|
8
9
|
import { LendingPoolData, LendingVaultData, LendingVaultPosition, TvlData, UserData, XimxData } from './offchainTypes';
|
|
9
10
|
import OffchainLendingVault from './offchainLendingVault';
|
|
@@ -35,6 +36,7 @@ export default class Offchain {
|
|
|
35
36
|
protected tvlData: Promise<TvlData> | null;
|
|
36
37
|
protected ximxData: Promise<XimxData> | null;
|
|
37
38
|
protected whitelistData: Promise<LendingPoolIndex<WhitelistState>> | null;
|
|
39
|
+
protected endpointManager: OffchainEndpointManager;
|
|
38
40
|
constructor(cfg: OffchainCfg);
|
|
39
41
|
cleanCache(): void;
|
|
40
42
|
getLendingPool(factory: Factory, pairAddress: Address): Promise<OffchainLendingPool>;
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -40,6 +40,7 @@ const offchainPriceHelper_1 = __importDefault(require("./offchainPriceHelper"));
|
|
|
40
40
|
const offchainAPRHelper_1 = __importDefault(require("./offchainAPRHelper"));
|
|
41
41
|
const offchainSolidexHelper_1 = __importDefault(require("./offchainSolidexHelper"));
|
|
42
42
|
const account_1 = __importDefault(require("./account"));
|
|
43
|
+
const offchainEndpointManager_1 = __importDefault(require("./offchainEndpointManager"));
|
|
43
44
|
const offchainLendingVault_1 = __importDefault(require("./offchainLendingVault"));
|
|
44
45
|
const configManager_1 = __importDefault(require("./configManager"));
|
|
45
46
|
class Offchain {
|
|
@@ -95,6 +96,7 @@ class Offchain {
|
|
|
95
96
|
this.solidexHelper = new offchainSolidexHelper_1.default(this);
|
|
96
97
|
this.configManager = new configManager_1.default(this);
|
|
97
98
|
this.aprHelper = new offchainAPRHelper_1.default(this);
|
|
99
|
+
this.endpointManager = new offchainEndpointManager_1.default();
|
|
98
100
|
this.accounts = {};
|
|
99
101
|
this.usersData = {};
|
|
100
102
|
this.lendingVaultsUsersData = {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DocumentNode } from "graphql";
|
|
2
|
+
import { IQueryBuilder } from "./queries/interfaces/query-builder";
|
|
3
|
+
import { Networks } from "../config/types";
|
|
4
|
+
export default class OffchainEndpointManager {
|
|
5
|
+
private endpoint;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Main fetcher function to query from multiple endpoints. The query MUST have _meta included.
|
|
9
|
+
*
|
|
10
|
+
* @param endpoints - Array of endpoints
|
|
11
|
+
* @param network - The network of the request (needed for the block due to ponder's `_meta` result)
|
|
12
|
+
* @param queryBuilder - The query requested from IQueryBuilder interface (ie. `lendingPoolQuery`, `tvlQuery`, etc.)
|
|
13
|
+
*/
|
|
14
|
+
fetch(endpoints: string[], network: Networks, queryBuilder: (builder: IQueryBuilder) => DocumentNode): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch a query from an endpoint (ponder, thegraph, etc.)
|
|
17
|
+
*/
|
|
18
|
+
private fetchFromEndpoint;
|
|
19
|
+
/**
|
|
20
|
+
* Given an array of responses from endpoint query, get the response wiht the latest block number
|
|
21
|
+
*/
|
|
22
|
+
private bestEndpointBlock;
|
|
23
|
+
private filterEndpoints;
|
|
24
|
+
private getPreferredEndpoint;
|
|
25
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const apollo_client_1 = __importDefault(require("apollo-client"));
|
|
16
|
+
const apollo_link_http_1 = require("apollo-link-http");
|
|
17
|
+
const apollo_cache_inmemory_1 = require("apollo-cache-inmemory");
|
|
18
|
+
const queries_1 = require("./queries");
|
|
19
|
+
class OffchainEndpointManager {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.endpoint = null;
|
|
22
|
+
// Get the param:
|
|
23
|
+
// 1. ?endpoint=thegraph for thegraph
|
|
24
|
+
// 2. ?endpoint=ibexer for ponder
|
|
25
|
+
// 3. none for both and picks the best of the 2
|
|
26
|
+
this.endpoint = this.getPreferredEndpoint(window.location.search);
|
|
27
|
+
}
|
|
28
|
+
// ---------------- Getter ---------------- //
|
|
29
|
+
/**
|
|
30
|
+
* Main fetcher function to query from multiple endpoints. The query MUST have _meta included.
|
|
31
|
+
*
|
|
32
|
+
* @param endpoints - Array of endpoints
|
|
33
|
+
* @param network - The network of the request (needed for the block due to ponder's `_meta` result)
|
|
34
|
+
* @param queryBuilder - The query requested from IQueryBuilder interface (ie. `lendingPoolQuery`, `tvlQuery`, etc.)
|
|
35
|
+
*/
|
|
36
|
+
fetch(endpoints, network, queryBuilder) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
// This is a test as we roll this out, to filter pass URL search param with thegraph or ibexer
|
|
39
|
+
const filteredEndpoints = this.filterEndpoints(endpoints);
|
|
40
|
+
if (filteredEndpoints.length === 0) {
|
|
41
|
+
console.warn("No endpoints available after filtering");
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const endpointQueries = filteredEndpoints.map(endpoint => ({
|
|
45
|
+
endpoint,
|
|
46
|
+
query: queryBuilder(queries_1.QueryBuilderFactory.getQuery(endpoint)),
|
|
47
|
+
}));
|
|
48
|
+
const endpointResults = yield Promise.allSettled(endpointQueries.map(eq => this.fetchFromEndpoint(eq)));
|
|
49
|
+
// If one endpoint breaks then it shouldnt break, filter it out and report
|
|
50
|
+
const responses = endpointResults
|
|
51
|
+
.filter((result, index) => {
|
|
52
|
+
if (result.status === "rejected") {
|
|
53
|
+
console.log(`${endpointQueries[index].endpoint} is down?`);
|
|
54
|
+
}
|
|
55
|
+
return result.status === 'fulfilled';
|
|
56
|
+
})
|
|
57
|
+
.map(result => result.value);
|
|
58
|
+
const latestResponse = this.bestEndpointBlock(responses, network);
|
|
59
|
+
if (!latestResponse) {
|
|
60
|
+
console.error("Cant find endpoint block");
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// Transform the data if needed in case of ponder or different api responses
|
|
64
|
+
return queries_1.QueryBuilderFactory.transformData(latestResponse.result);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// ---------------- Private ---------------- //
|
|
68
|
+
/**
|
|
69
|
+
* Fetch a query from an endpoint (ponder, thegraph, etc.)
|
|
70
|
+
*/
|
|
71
|
+
fetchFromEndpoint({ endpoint, query }) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const client = new apollo_client_1.default({
|
|
74
|
+
link: new apollo_link_http_1.HttpLink({ uri: endpoint }),
|
|
75
|
+
cache: new apollo_cache_inmemory_1.InMemoryCache()
|
|
76
|
+
});
|
|
77
|
+
const result = yield client.query({
|
|
78
|
+
query,
|
|
79
|
+
fetchPolicy: 'cache-first'
|
|
80
|
+
});
|
|
81
|
+
return { endpoint, result };
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Given an array of responses from endpoint query, get the response wiht the latest block number
|
|
86
|
+
*/
|
|
87
|
+
bestEndpointBlock(responses, network) {
|
|
88
|
+
if (!responses.length)
|
|
89
|
+
return null;
|
|
90
|
+
let bestEndpoint = responses[0];
|
|
91
|
+
let maxBlockNumber = 0;
|
|
92
|
+
for (const response of responses) {
|
|
93
|
+
const queryBuilder = queries_1.QueryBuilderFactory.getQuery(response.endpoint);
|
|
94
|
+
const blockNumber = queryBuilder.getBlockNumber(response.result, network);
|
|
95
|
+
if (blockNumber > maxBlockNumber && response.result.data) {
|
|
96
|
+
maxBlockNumber = blockNumber;
|
|
97
|
+
bestEndpoint = response;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return Object.assign(Object.assign({}, bestEndpoint), { maxBlockNumber });
|
|
101
|
+
}
|
|
102
|
+
// ---------------- Monitoring ---------------- //
|
|
103
|
+
filterEndpoints(endpoints) {
|
|
104
|
+
// No endpoint passed, ignore
|
|
105
|
+
if (!this.endpoint)
|
|
106
|
+
return endpoints;
|
|
107
|
+
const preferredEndpoint = this.endpoint === "thegraph" ? "thegraph" : "railway";
|
|
108
|
+
return endpoints.filter(endpoint => endpoint.includes(preferredEndpoint));
|
|
109
|
+
}
|
|
110
|
+
getPreferredEndpoint(searchParams) {
|
|
111
|
+
const urlParams = new URLSearchParams(searchParams);
|
|
112
|
+
const endpoint = urlParams.get("endpoint");
|
|
113
|
+
if (!endpoint)
|
|
114
|
+
return null;
|
|
115
|
+
switch (endpoint.toLowerCase()) {
|
|
116
|
+
case "thegraph":
|
|
117
|
+
return "thegraph";
|
|
118
|
+
case "ibexer":
|
|
119
|
+
return "ibexer";
|
|
120
|
+
default:
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.default = OffchainEndpointManager;
|