impermax-sdk 1.2.63 → 1.2.65
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 +12 -0
- package/lib/config/contracts/claim-aggregators.js +1 -0
- package/lib/config/contracts/impermax-chef.js +1 -0
- package/lib/config/contracts/impermax-config-manager.js +1 -0
- package/lib/config/contracts/impermax-factories.js +3 -0
- package/lib/config/contracts/imxes.js +1 -0
- package/lib/config/contracts/lending-vault-watcher.js +1 -0
- package/lib/config/contracts/merkle-distributors.js +3 -0
- package/lib/config/contracts/routers.js +4 -0
- package/lib/config/contracts/simple-uniswap-oracles.js +1 -0
- package/lib/config/contracts/weths.js +2 -1
- package/lib/config/debank-ids.js +1 -0
- package/lib/config/endpoints/merkle-distributors.js +3 -0
- package/lib/config/eth.js +2 -0
- package/lib/config/farms.d.ts +3 -1
- package/lib/config/farms.js +5 -0
- package/lib/config/subgraphs.d.ts +1 -0
- package/lib/config/subgraphs.js +7 -0
- package/lib/config/types.d.ts +2 -1
- package/lib/config/types.js +1 -0
- package/lib/offchain/account/lendingPool/borrowable.d.ts +14 -0
- package/lib/offchain/account/lendingPool/borrowable.js +73 -0
- package/lib/offchain/account/lendingPool/collateral.d.ts +12 -0
- package/lib/offchain/account/lendingPool/collateral.js +42 -0
- package/lib/offchain/account/lendingVault.d.ts +11 -0
- package/lib/offchain/account/lendingVault.js +38 -0
- package/lib/offchain/account/poolToken.d.ts +6 -0
- package/lib/offchain/account/poolToken.js +21 -0
- package/lib/offchain/initializer.d.ts +32 -0
- package/lib/offchain/initializer.js +627 -0
- package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
- package/lib/offchain/lendingPool/borrowable.js +351 -0
- package/lib/offchain/lendingPool/collateral.d.ts +17 -0
- package/lib/offchain/lendingPool/collateral.js +72 -0
- package/lib/offchain/lendingVault.d.ts +22 -0
- package/lib/offchain/lendingVault.js +115 -0
- package/lib/offchain/offchainAPRHelper.js +2 -1
- package/lib/offchain/offchainInitializer.js +2 -0
- package/lib/offchain/poolToken.d.ts +20 -0
- package/lib/offchain/poolToken.js +120 -0
- package/lib/offchain/priceHelper.d.ts +21 -0
- package/lib/offchain/priceHelper.js +195 -0
- package/lib/offchain/query.js +247 -247
- package/lib/offchain/solidexHelper.d.ts +16 -0
- package/lib/offchain/solidexHelper.js +58 -0
- package/lib/offchain/types.d.ts +150 -0
- package/lib/offchain/types.js +3 -0
- package/lib/onchain/account/interactions/index.d.ts +28 -0
- package/lib/onchain/account/interactions/index.js +158 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
- package/lib/onchain/account/interactions/lendingPool/borrowable.js +49 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/interactions/lendingPool/collateral.js +33 -0
- package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
- package/lib/onchain/account/interactions/lendingPool/index.js +120 -0
- package/lib/onchain/account/interactions/lendingVault.d.ts +10 -0
- package/lib/onchain/account/interactions/lendingVault.js +12 -0
- package/lib/onchain/account/interactions/poolToken.d.ts +33 -0
- package/lib/onchain/account/interactions/poolToken.js +180 -0
- package/lib/onchain/account/lendingPool/borrowable.d.ts +29 -0
- package/lib/onchain/account/lendingPool/borrowable.js +135 -0
- package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
- package/lib/onchain/account/lendingPool/collateral.js +66 -0
- package/lib/onchain/account/lendingVault.d.ts +10 -0
- package/lib/onchain/account/lendingVault.js +35 -0
- package/lib/onchain/account/poolToken.d.ts +24 -0
- package/lib/onchain/account/poolToken.js +84 -0
- package/lib/onchain/contractsHelper.d.ts +29 -0
- package/lib/onchain/contractsHelper.js +52 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +153 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +17 -0
- package/lib/onchain/impermaxFactory/lendingPool/collateral.js +59 -0
- package/lib/onchain/interactions/lendingPool/borrowable.d.ts +14 -0
- package/lib/onchain/interactions/lendingPool/borrowable.js +47 -0
- package/lib/onchain/interactions/lendingPool/collateral.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/collateral.js +31 -0
- package/lib/onchain/interactions/lendingVault.d.ts +8 -0
- package/lib/onchain/interactions/lendingVault.js +15 -0
- package/lib/onchain/interactions/poolToken.d.ts +31 -0
- package/lib/onchain/interactions/poolToken.js +181 -0
- package/lib/onchain/lendingVault.d.ts +17 -0
- package/lib/onchain/lendingVault.js +56 -0
- package/lib/onchain/poolToken.d.ts +32 -0
- package/lib/onchain/poolToken.js +121 -0
- package/lib/onchain/types.d.ts +45 -0
- package/lib/onchain/types.js +14 -0
- package/lib/utils/price-from-reserves.d.ts +2 -0
- package/lib/utils/price-from-reserves.js +19 -0
- package/package.json +1 -1
package/lib/config/amms.d.ts
CHANGED
|
@@ -38,7 +38,8 @@ export declare enum Amms {
|
|
|
38
38
|
tokan = "tokan",
|
|
39
39
|
tokanStable = "tokanStable",
|
|
40
40
|
scale = "scale",
|
|
41
|
-
equalizer = "equalizer"
|
|
41
|
+
equalizer = "equalizer",
|
|
42
|
+
velodrome = "velodrome"
|
|
42
43
|
}
|
|
43
44
|
export declare const hrAmms: {
|
|
44
45
|
uniswap: string;
|
|
@@ -80,6 +81,7 @@ export declare const hrAmms: {
|
|
|
80
81
|
tokan: string;
|
|
81
82
|
tokanStable: string;
|
|
82
83
|
equalizer: string;
|
|
84
|
+
velodrome: string;
|
|
83
85
|
};
|
|
84
86
|
export declare const AMM_FACTORY: AmmIndex;
|
|
85
87
|
export declare function getAmmByFactory(network: Networks, address: Address): Amms | null;
|
package/lib/config/amms.js
CHANGED
|
@@ -43,6 +43,7 @@ var Amms;
|
|
|
43
43
|
Amms["tokanStable"] = "tokanStable";
|
|
44
44
|
Amms["scale"] = "scale";
|
|
45
45
|
Amms["equalizer"] = "equalizer";
|
|
46
|
+
Amms["velodrome"] = "velodrome";
|
|
46
47
|
})(Amms = exports.Amms || (exports.Amms = {}));
|
|
47
48
|
exports.hrAmms = {
|
|
48
49
|
[Amms.uniswap]: 'Uniswap',
|
|
@@ -84,6 +85,7 @@ exports.hrAmms = {
|
|
|
84
85
|
[Amms.tokan]: 'Tokan',
|
|
85
86
|
[Amms.tokanStable]: 'Tokan Stable',
|
|
86
87
|
[Amms.equalizer]: 'Equalizer',
|
|
88
|
+
[Amms.velodrome]: 'Velodrome',
|
|
87
89
|
};
|
|
88
90
|
exports.AMM_FACTORY = {
|
|
89
91
|
[types_1.Networks.Ropsten]: {
|
|
@@ -157,6 +159,9 @@ exports.AMM_FACTORY = {
|
|
|
157
159
|
[types_1.Networks.Scroll]: {
|
|
158
160
|
[Amms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
159
161
|
[Amms.tokanStable]: '0x6c041ff2d25310a2751C57555265F2364CaCA195', //NOTICE: this is actually the staked LP factory
|
|
162
|
+
},
|
|
163
|
+
[types_1.Networks.Optimism]: {
|
|
164
|
+
[Amms.velodrome]: '0x47183bB55AD0F891887E099Cec3570d3C667cD00', //NOTICE: this is actually the staked LP factory
|
|
160
165
|
}
|
|
161
166
|
};
|
|
162
167
|
function getAmmByFactory(network, address) {
|
|
@@ -225,6 +230,7 @@ exports.AMM_SUBGRAPH_URLS = {
|
|
|
225
230
|
},
|
|
226
231
|
[types_1.Networks.Mantle]: {},
|
|
227
232
|
[types_1.Networks.Scroll]: {},
|
|
233
|
+
[types_1.Networks.Optimism]: {},
|
|
228
234
|
};
|
|
229
235
|
exports.ADD_LIQUIDITY_URLS = {
|
|
230
236
|
[types_1.Networks.Ropsten]: {
|
|
@@ -299,6 +305,9 @@ exports.ADD_LIQUIDITY_URLS = {
|
|
|
299
305
|
[Amms.tokan]: 'https://app.tokan.exchange/liquidity/',
|
|
300
306
|
[Amms.tokanStable]: 'https://app.tokan.exchange/liquidity/',
|
|
301
307
|
},
|
|
308
|
+
[types_1.Networks.Optimism]: {
|
|
309
|
+
[Amms.velodrome]: 'https://velodrome.finance/deposit/',
|
|
310
|
+
}
|
|
302
311
|
};
|
|
303
312
|
exports.AMM_LP_FEE = {
|
|
304
313
|
[types_1.Networks.Ropsten]: {
|
|
@@ -372,5 +381,8 @@ exports.AMM_LP_FEE = {
|
|
|
372
381
|
},
|
|
373
382
|
[types_1.Networks.Mantle]: {
|
|
374
383
|
[Amms.merchantmoe]: 0.003,
|
|
384
|
+
},
|
|
385
|
+
[types_1.Networks.Optimism]: {
|
|
386
|
+
[Amms.velodrome]: 0,
|
|
375
387
|
}
|
|
376
388
|
};
|
|
@@ -20,4 +20,5 @@ exports.IMPERMAX_CONFIG_MANAGER = {
|
|
|
20
20
|
[types_1.Networks.Base]: '0x9acafcb281e94eaB771D0cf6508c92A4B75DCE7c',
|
|
21
21
|
[types_1.Networks.Scroll]: '0x90869a451f966d848b85Da57e2a65A545AFb6087',
|
|
22
22
|
[types_1.Networks.Mantle]: '0x6daC1AbEA1E903765358EFD4Ac4e6E817F78F4CB',
|
|
23
|
+
[types_1.Networks.Optimism]: '0xC8301bD3f86e642904aeD9b588cA9d9350b3B160',
|
|
23
24
|
};
|
|
@@ -53,6 +53,9 @@ exports.IMPERMAX_FACTORY = {
|
|
|
53
53
|
[types_1.Networks.Mantle]: {
|
|
54
54
|
[types_1.Factory.V2V2]: '0x3047523D5ed0df1545B1C440BdAaB095f1f3cf5C'
|
|
55
55
|
},
|
|
56
|
+
[types_1.Networks.Optimism]: {
|
|
57
|
+
[types_1.Factory.SOLV2]: '0xa058Ba91958cD30D44c7B0Cf58A369876Fb70B05',
|
|
58
|
+
},
|
|
56
59
|
};
|
|
57
60
|
function getFactoryByAddress(network, address) {
|
|
58
61
|
if (!address)
|
|
@@ -20,6 +20,7 @@ exports.MERKLE_DISTRIBUTOR_IBEX = {
|
|
|
20
20
|
[types_1.Networks.Base]: '',
|
|
21
21
|
[types_1.Networks.Mantle]: '',
|
|
22
22
|
[types_1.Networks.Scroll]: '',
|
|
23
|
+
[types_1.Networks.Optimism]: '',
|
|
23
24
|
};
|
|
24
25
|
exports.MERKLE_DISTRIBUTOR_IBEX_2 = {
|
|
25
26
|
[types_1.Networks.Polygon]: '0x1c813cDd6dAecE2CB83C52F0798504e42816E9C5',
|
|
@@ -39,6 +40,7 @@ exports.MERKLE_DISTRIBUTOR_IBEX_2 = {
|
|
|
39
40
|
[types_1.Networks.Base]: '',
|
|
40
41
|
[types_1.Networks.Mantle]: '',
|
|
41
42
|
[types_1.Networks.Scroll]: '',
|
|
43
|
+
[types_1.Networks.Optimism]: '',
|
|
42
44
|
};
|
|
43
45
|
exports.MERKLE_DISTRIBUTOR_ETH = {
|
|
44
46
|
[types_1.Networks.Polygon]: '0x7ce2f634f0698ecdca051ef1dc4be96ef3d05a62',
|
|
@@ -58,4 +60,5 @@ exports.MERKLE_DISTRIBUTOR_ETH = {
|
|
|
58
60
|
[types_1.Networks.Base]: '',
|
|
59
61
|
[types_1.Networks.Mantle]: '',
|
|
60
62
|
[types_1.Networks.Scroll]: '',
|
|
63
|
+
[types_1.Networks.Optimism]: '',
|
|
61
64
|
};
|
|
@@ -54,6 +54,9 @@ exports.ROUTER = {
|
|
|
54
54
|
[types_1.Factory.SOLV2]: '0xFF8D0CDC9C857c7fA265121394558B26e1eAAffE',
|
|
55
55
|
[types_1.Factory.SOL_STABLE]: '0x736176788edef99D2FAbfAa0f5e13BCb3b46bE17'
|
|
56
56
|
},
|
|
57
|
+
[types_1.Networks.Optimism]: {
|
|
58
|
+
[types_1.Factory.SOLV2]: '0xb5657FA5ba87CaD11b9150c319069625d423aaD4',
|
|
59
|
+
},
|
|
57
60
|
[types_1.Networks.Mantle]: {
|
|
58
61
|
[types_1.Factory.V2V2]: '0xF4A9dda025e65945E7A3F873D6146A12c8110A19'
|
|
59
62
|
},
|
|
@@ -76,4 +79,5 @@ exports.DEFAULT_ROUTER = {
|
|
|
76
79
|
[types_1.Networks.Base]: '0x1EBC3b5911B99aDdE07944c75D9E03958abdB49f',
|
|
77
80
|
[types_1.Networks.Scroll]: '0xFF8D0CDC9C857c7fA265121394558B26e1eAAffE',
|
|
78
81
|
[types_1.Networks.Mantle]: '0xF4A9dda025e65945E7A3F873D6146A12c8110A19',
|
|
82
|
+
[types_1.Networks.Optimism]: '0xb5657FA5ba87CaD11b9150c319069625d423aaD4',
|
|
79
83
|
};
|
|
@@ -38,6 +38,7 @@ exports.SIMPLE_UNISWAP_ORACLE = {
|
|
|
38
38
|
[types_1.Factory.V2V2]: "0x1fd55593ccD75e5727bb71bEB155e86d7290eAD6"
|
|
39
39
|
},
|
|
40
40
|
[types_1.Networks.Scroll]: {},
|
|
41
|
+
[types_1.Networks.Optimism]: {},
|
|
41
42
|
[types_1.Networks.Mantle]: {
|
|
42
43
|
[types_1.Factory.V2V2]: '0x936c30E14daED88fd29bf4FCe2965EbEDe633846'
|
|
43
44
|
},
|
|
@@ -20,5 +20,6 @@ exports.WETH = {
|
|
|
20
20
|
[types_1.Networks.ZksyncEra]: '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91',
|
|
21
21
|
[types_1.Networks.Base]: '0x4200000000000000000000000000000000000006',
|
|
22
22
|
[types_1.Networks.Mantle]: '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8',
|
|
23
|
-
[types_1.Networks.Scroll]: '0x5300000000000000000000000000000000000004',
|
|
23
|
+
[types_1.Networks.Scroll]: '0x5300000000000000000000000000000000000004',
|
|
24
|
+
[types_1.Networks.Optimism]: '0x4200000000000000000000000000000000000006', // WETH
|
|
24
25
|
};
|
package/lib/config/debank-ids.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.MERKLE_URL_IBEX = {
|
|
|
20
20
|
[types_1.Networks.Base]: '',
|
|
21
21
|
[types_1.Networks.Mantle]: '',
|
|
22
22
|
[types_1.Networks.Scroll]: '',
|
|
23
|
+
[types_1.Networks.Optimism]: '',
|
|
23
24
|
};
|
|
24
25
|
exports.MERKLE_URL_IBEX_2 = {
|
|
25
26
|
[types_1.Networks.Polygon]: 'https://misty-rice-9880.impermax.workers.dev',
|
|
@@ -39,6 +40,7 @@ exports.MERKLE_URL_IBEX_2 = {
|
|
|
39
40
|
[types_1.Networks.Base]: '',
|
|
40
41
|
[types_1.Networks.Mantle]: '',
|
|
41
42
|
[types_1.Networks.Scroll]: '',
|
|
43
|
+
[types_1.Networks.Optimism]: '',
|
|
42
44
|
};
|
|
43
45
|
exports.MERKLE_URL_ETH = {
|
|
44
46
|
[types_1.Networks.Polygon]: 'https://damp-hill-13d0.impermax.workers.dev',
|
|
@@ -58,4 +60,5 @@ exports.MERKLE_URL_ETH = {
|
|
|
58
60
|
[types_1.Networks.Base]: '',
|
|
59
61
|
[types_1.Networks.Mantle]: '',
|
|
60
62
|
[types_1.Networks.Scroll]: '',
|
|
63
|
+
[types_1.Networks.Optimism]: '',
|
|
61
64
|
};
|
package/lib/config/eth.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.ETH_NAME = {
|
|
|
20
20
|
[types_1.Networks.Base]: 'Ethereum',
|
|
21
21
|
[types_1.Networks.Mantle]: 'Mantle',
|
|
22
22
|
[types_1.Networks.Scroll]: 'Ethereum',
|
|
23
|
+
[types_1.Networks.Optimism]: 'Ethereum',
|
|
23
24
|
};
|
|
24
25
|
exports.ETH_SYMBOL = {
|
|
25
26
|
[types_1.Networks.Ropsten]: 'ETH',
|
|
@@ -39,4 +40,5 @@ exports.ETH_SYMBOL = {
|
|
|
39
40
|
[types_1.Networks.Base]: 'ETH',
|
|
40
41
|
[types_1.Networks.Mantle]: 'MNT',
|
|
41
42
|
[types_1.Networks.Scroll]: 'ETH',
|
|
43
|
+
[types_1.Networks.Optimism]: 'ETH',
|
|
42
44
|
};
|
package/lib/config/farms.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ export declare enum Farms {
|
|
|
43
43
|
aeroStable = "aeroStable",
|
|
44
44
|
merchantmoe = "merchantmoe",
|
|
45
45
|
tokan = "tokan",
|
|
46
|
-
tokanStable = "tokanStable"
|
|
46
|
+
tokanStable = "tokanStable",
|
|
47
|
+
velodrome = "velodrome"
|
|
47
48
|
}
|
|
48
49
|
export declare const hrFarms: {
|
|
49
50
|
quickswapOld: string;
|
|
@@ -89,6 +90,7 @@ export declare const hrFarms: {
|
|
|
89
90
|
aeroStable: string;
|
|
90
91
|
tokan: string;
|
|
91
92
|
tokanStable: string;
|
|
93
|
+
velodrome: string;
|
|
92
94
|
};
|
|
93
95
|
export type FarmIndex = {
|
|
94
96
|
[key in Networks]: {
|
package/lib/config/farms.js
CHANGED
|
@@ -48,6 +48,7 @@ var Farms;
|
|
|
48
48
|
Farms["merchantmoe"] = "merchantmoe";
|
|
49
49
|
Farms["tokan"] = "tokan";
|
|
50
50
|
Farms["tokanStable"] = "tokanStable";
|
|
51
|
+
Farms["velodrome"] = "velodrome";
|
|
51
52
|
})(Farms = exports.Farms || (exports.Farms = {}));
|
|
52
53
|
exports.hrFarms = {
|
|
53
54
|
[Farms.quickswapOld]: 'QuickSwap',
|
|
@@ -93,6 +94,7 @@ exports.hrFarms = {
|
|
|
93
94
|
[Farms.aeroStable]: 'Aerodrome Stable',
|
|
94
95
|
[Farms.tokan]: 'Tokan',
|
|
95
96
|
[Farms.tokanStable]: 'Tokan Stable',
|
|
97
|
+
[Farms.velodrome]: 'Velodrome',
|
|
96
98
|
};
|
|
97
99
|
exports.STAKED_LP_FACTORY = {
|
|
98
100
|
[types_1.Networks.Ropsten]: {},
|
|
@@ -168,6 +170,9 @@ exports.STAKED_LP_FACTORY = {
|
|
|
168
170
|
[types_1.Networks.Scroll]: {
|
|
169
171
|
[Farms.tokan]: '0x074568F090e93194289c2C2BF285eE7f60b485a9',
|
|
170
172
|
[Farms.tokanStable]: '0x6c041ff2d25310a2751C57555265F2364CaCA195',
|
|
173
|
+
},
|
|
174
|
+
[types_1.Networks.Optimism]: {
|
|
175
|
+
[Farms.velodrome]: '0x47183bB55AD0F891887E099Cec3570d3C667cD00',
|
|
171
176
|
}
|
|
172
177
|
};
|
|
173
178
|
function getFarmByStakedLPFactory(network, address) {
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -53,6 +53,9 @@ exports.IMPERMAX_SUBGRAPH_URL = {
|
|
|
53
53
|
[types_1.Factory.SOLV2]: 'https://api.studio.thegraph.com/query/46041/impermax-scroll-solv2/v0.0.1',
|
|
54
54
|
[types_1.Factory.SOL_STABLE]: 'https://api.studio.thegraph.com/query/46041/impermax-scroll-solv2-stable/v0.0.4'
|
|
55
55
|
},
|
|
56
|
+
[types_1.Networks.Optimism]: {
|
|
57
|
+
[types_1.Factory.SOLV2]: 'https://api.studio.thegraph.com/query/46041/impermax-optimism-solv2/v0.0.1'
|
|
58
|
+
},
|
|
56
59
|
};
|
|
57
60
|
exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
|
58
61
|
[types_1.Networks.Ropsten]: '',
|
|
@@ -73,6 +76,7 @@ exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
|
|
73
76
|
[types_1.Networks.Base]: '',
|
|
74
77
|
[types_1.Networks.Mantle]: '',
|
|
75
78
|
[types_1.Networks.Scroll]: '',
|
|
79
|
+
[types_1.Networks.Optimism]: '',
|
|
76
80
|
};
|
|
77
81
|
exports.LENDING_VAULT_SUBGRAPH_URL = {
|
|
78
82
|
[types_1.Networks.Ropsten]: '',
|
|
@@ -91,6 +95,7 @@ exports.LENDING_VAULT_SUBGRAPH_URL = {
|
|
|
91
95
|
[types_1.Networks.ZksyncEra]: '',
|
|
92
96
|
[types_1.Networks.Base]: 'https://api.studio.thegraph.com/query/46041/lending-vault-base/v0.0.1',
|
|
93
97
|
[types_1.Networks.Mantle]: '',
|
|
98
|
+
[types_1.Networks.Optimism]: '',
|
|
94
99
|
[types_1.Networks.Scroll]: 'https://api.studio.thegraph.com/query/46041/lending-vault-scroll/v0.0.1',
|
|
95
100
|
};
|
|
96
101
|
exports.BLOCKS_SUBGRAPH_URL = {
|
|
@@ -111,6 +116,7 @@ exports.BLOCKS_SUBGRAPH_URL = {
|
|
|
111
116
|
[types_1.Networks.Base]: 'https://api.thegraph.com/subgraphs/name/blocklytics/base-blocks',
|
|
112
117
|
[types_1.Networks.Mantle]: '',
|
|
113
118
|
[types_1.Networks.Scroll]: '',
|
|
119
|
+
[types_1.Networks.Optimism]: '',
|
|
114
120
|
};
|
|
115
121
|
exports.XIMX_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/impermax-finance/imx-staking";
|
|
116
122
|
exports.CONFIG_MANAGER_SUBGRAPH_URL = {
|
|
@@ -130,6 +136,7 @@ exports.CONFIG_MANAGER_SUBGRAPH_URL = {
|
|
|
130
136
|
[types_1.Networks.Sxnetwork]: '',
|
|
131
137
|
[types_1.Networks.Scroll]: 'https://api.studio.thegraph.com/query/46041/impermax-config-manager-scroll/v0.0.1',
|
|
132
138
|
[types_1.Networks.Base]: 'https://api.studio.thegraph.com/query/46041/impermax-config-manager-base/v0.0.1',
|
|
139
|
+
[types_1.Networks.Optimism]: 'https://api.studio.thegraph.com/query/46041/impermax-config-manager-op/v0.0.1',
|
|
133
140
|
};
|
|
134
141
|
exports.WHITELIST_SUBGRAPH_URL = {
|
|
135
142
|
[types_1.Networks.Ropsten]: '',
|
package/lib/config/types.d.ts
CHANGED
package/lib/config/types.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PoolTokenType } from '../../../config/types';
|
|
2
|
+
import LendingPool from './index';
|
|
3
|
+
import PoolToken from '../poolToken';
|
|
4
|
+
import * as offchain from '../../index';
|
|
5
|
+
export default class Borrowable extends PoolToken {
|
|
6
|
+
accountLendingPool: LendingPool;
|
|
7
|
+
poolToken: offchain.lendingPool.Borrowable;
|
|
8
|
+
constructor(accountLendingPool: LendingPool, poolTokenType: PoolTokenType);
|
|
9
|
+
private getSupplyPosition;
|
|
10
|
+
getAmount(): Promise<number>;
|
|
11
|
+
private getBorrowPosition;
|
|
12
|
+
getBorrowedAmount(): Promise<number>;
|
|
13
|
+
getBorrowedValue(): Promise<number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 poolToken_1 = __importDefault(require("../poolToken"));
|
|
16
|
+
class Borrowable extends poolToken_1.default {
|
|
17
|
+
constructor(accountLendingPool, poolTokenType) {
|
|
18
|
+
super();
|
|
19
|
+
this.accountLendingPool = accountLendingPool;
|
|
20
|
+
this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
|
|
21
|
+
}
|
|
22
|
+
getSupplyPosition() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const userData = yield this.lendingPool.getUserData();
|
|
25
|
+
if (!userData)
|
|
26
|
+
return undefined;
|
|
27
|
+
const supplyPositions = userData.supplyPositions[this.offchainPoolToken.lendingPool.pairAddress];
|
|
28
|
+
if (!supplyPositions)
|
|
29
|
+
return undefined;
|
|
30
|
+
return supplyPositions[this.offchainPoolToken.poolTokenType];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getAmount() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const supplyPosition = yield this.getSupplyPosition();
|
|
36
|
+
if (!supplyPosition)
|
|
37
|
+
return 0;
|
|
38
|
+
const exchangeRate = yield this.offchainPoolToken.getExchangeRate();
|
|
39
|
+
const supplyBalance = parseFloat(supplyPosition.balance);
|
|
40
|
+
return supplyBalance * exchangeRate;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getBorrowPosition() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const userData = yield this.lendingPool.getUserData();
|
|
46
|
+
if (!userData)
|
|
47
|
+
return undefined;
|
|
48
|
+
const borrowPositions = userData.borrowPositions[this.offchainPoolToken.lendingPool.pairAddress];
|
|
49
|
+
if (!borrowPositions)
|
|
50
|
+
return undefined;
|
|
51
|
+
return borrowPositions[this.offchainPoolToken.poolTokenType];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getBorrowedAmount() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const borrowPosition = yield this.getBorrowPosition();
|
|
57
|
+
const borrowIndex = yield this.offchainPoolToken.getBorrowIndex();
|
|
58
|
+
if (!borrowPosition)
|
|
59
|
+
return 0;
|
|
60
|
+
const borrowBalance = parseFloat(borrowPosition.borrowBalance);
|
|
61
|
+
const userBorrowIndex = parseFloat(borrowPosition.borrowIndex);
|
|
62
|
+
return borrowBalance * borrowIndex / userBorrowIndex;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
getBorrowedValue() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const tokenPrice = yield this.offchainPoolToken.getTokenPriceAccurate();
|
|
68
|
+
const borrowedAmount = yield this.getBorrowedAmount();
|
|
69
|
+
return borrowedAmount * tokenPrice;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = Borrowable;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CollateralPosition } from "../../types";
|
|
2
|
+
import { PoolTokenType } from '../../../config/types';
|
|
3
|
+
import LendingPool from './index';
|
|
4
|
+
import PoolToken from '../poolToken';
|
|
5
|
+
import * as offchain from '../../index';
|
|
6
|
+
export default class Collateral extends PoolToken {
|
|
7
|
+
accountLendingPool: LendingPool;
|
|
8
|
+
poolToken: offchain.lendingPool.Collateral;
|
|
9
|
+
constructor(accountLendingPool: LendingPool, poolTokenType: PoolTokenType);
|
|
10
|
+
getCollateralPosition(): Promise<CollateralPosition | undefined>;
|
|
11
|
+
getAmount(): Promise<number>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 types_1 = require("../../../config/types");
|
|
16
|
+
const poolToken_1 = __importDefault(require("../poolToken"));
|
|
17
|
+
class Collateral extends poolToken_1.default {
|
|
18
|
+
constructor(accountLendingPool, poolTokenType) {
|
|
19
|
+
super();
|
|
20
|
+
this.accountLendingPool = accountLendingPool;
|
|
21
|
+
this.poolToken = accountLendingPool.lendingPool.poolTokens[poolTokenType];
|
|
22
|
+
}
|
|
23
|
+
getCollateralPosition() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const userData = yield this.lendingPool.getUserData();
|
|
26
|
+
if (!userData)
|
|
27
|
+
return undefined;
|
|
28
|
+
return userData.collateralPositions[this.offchainPoolToken.lendingPool.pairAddress];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
getAmount() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const collateralPosition = yield this.getCollateralPosition();
|
|
34
|
+
if (!collateralPosition)
|
|
35
|
+
return 0;
|
|
36
|
+
const exchangeRate = yield this.offchainPoolToken.lendingPool.poolTokens[types_1.PoolTokenType.Collateral].getExchangeRate();
|
|
37
|
+
const collateralBalance = parseFloat(collateralPosition.balance);
|
|
38
|
+
return collateralBalance * exchangeRate;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = Collateral;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as offchain from '../index';
|
|
2
|
+
import Account from './index';
|
|
3
|
+
import PoolToken from './poolToken';
|
|
4
|
+
export default class LendingVault extends PoolToken {
|
|
5
|
+
account: Account;
|
|
6
|
+
poolToken: offchain.LendingVault;
|
|
7
|
+
constructor(account: Account, lendingVault: offchain.LendingVault);
|
|
8
|
+
getAmount(): Promise<number>;
|
|
9
|
+
getEarnings(): Promise<number>;
|
|
10
|
+
getEarningsUSD(): Promise<number>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 poolToken_1 = __importDefault(require("./poolToken"));
|
|
16
|
+
class LendingVault extends poolToken_1.default {
|
|
17
|
+
constructor(account, lendingVault) {
|
|
18
|
+
super();
|
|
19
|
+
this.account = account;
|
|
20
|
+
this.poolToken = lendingVault;
|
|
21
|
+
}
|
|
22
|
+
getAmount() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return 0;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getEarnings() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return 0;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
getEarningsUSD() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return 0;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = LendingVault;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
class PoolToken {
|
|
13
|
+
getValue() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const tokenPrice = yield this.offchainPoolToken.getTokenPriceAccurate();
|
|
16
|
+
const amount = yield this.getAmount();
|
|
17
|
+
return amount * tokenPrice;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = PoolToken;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApolloQueryResult } from "apollo-client";
|
|
2
|
+
import Offchain from "./index";
|
|
3
|
+
import { DocumentNode } from "graphql";
|
|
4
|
+
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex } from '../config/types';
|
|
5
|
+
import { Amms } from '../config/amms';
|
|
6
|
+
import { LendingPoolData, RawUserData, TvlData, UserData, XimxData } from './types';
|
|
7
|
+
export declare function apolloFetcher(subgraphUrl: string, query: DocumentNode): Promise<ApolloQueryResult<any>>;
|
|
8
|
+
export declare function fetchBlockByTimestamp(this: Offchain, timestamp: number): Promise<number | null>;
|
|
9
|
+
export declare function fetchLendingPools(this: Offchain): Promise<FactoryIndex<LendingPoolData[]>>;
|
|
10
|
+
export declare function fetchLendingPoolsPast(this: Offchain, seconds: number): Promise<FactoryIndex<any[]> | null>;
|
|
11
|
+
export declare function fetchImpermaxChefRewardRates(this: Offchain): Promise<AddressIndex<Array<{
|
|
12
|
+
rewardToken: Address;
|
|
13
|
+
rewardRate: number;
|
|
14
|
+
}>> | null>;
|
|
15
|
+
export declare function fetchPastVolume(this: Offchain, amm: Amms, lendingPools: LendingPoolData[], seconds: number): Promise<AddressIndex<number>>;
|
|
16
|
+
export declare function fetchCurrentVolumeAndReserves(this: Offchain, amm: Amms, lendingPools: LendingPoolData[]): Promise<{
|
|
17
|
+
currentVolume: AddressIndex<number>;
|
|
18
|
+
currentReserve: AddressIndex<number>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function fetchUniswapAPR(this: Offchain, lendingPoolsByAmm: {
|
|
21
|
+
[key in Amms]?: LendingPoolData[];
|
|
22
|
+
}, seconds?: number): Promise<AddressIndex<number>>;
|
|
23
|
+
export declare function initializeLendingPoolsData(this: Offchain): Promise<LendingPoolIndex<LendingPoolData>>;
|
|
24
|
+
export declare function getLendingPoolsData(this: Offchain): Promise<LendingPoolIndex<LendingPoolData>>;
|
|
25
|
+
export declare function getLendingPoolData(this: Offchain, factory: Factory, uniswapV2PairAddress: Address): Promise<LendingPoolData>;
|
|
26
|
+
export declare function initializeTvlData(this: Offchain): Promise<TvlData>;
|
|
27
|
+
export declare function getTvlData(this: Offchain): Promise<TvlData>;
|
|
28
|
+
export declare function fetchUserData(this: Offchain, account: Address): Promise<FactoryIndex<RawUserData>>;
|
|
29
|
+
export declare function initializeUserData(this: Offchain, account: Address): Promise<FactoryIndex<UserData> | null>;
|
|
30
|
+
export declare function getUserData(this: Offchain, account: Address): Promise<FactoryIndex<UserData> | null>;
|
|
31
|
+
export declare function initializeXimxData(this: Offchain): Promise<XimxData>;
|
|
32
|
+
export declare function getXimxData(this: Offchain): Promise<XimxData>;
|