@curvefi/llamalend-api 2.2.2 → 2.2.4
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.
|
@@ -83,7 +83,7 @@ export const getFactoryMarketDataV2 = (llamalend) => __awaiter(void 0, void 0, v
|
|
|
83
83
|
const collateral_tokens = [];
|
|
84
84
|
const borrowed_tokens = [];
|
|
85
85
|
const monetary_policies = [];
|
|
86
|
-
const gauges =
|
|
86
|
+
const gauges = new Array(Number(markets_count)).fill(llamalend.constants.ZERO_ADDRESS);
|
|
87
87
|
for (let i = 0; i < markets_count; i++) {
|
|
88
88
|
const marketData = res[i];
|
|
89
89
|
vaults.push(marketData[0].toLowerCase());
|
|
@@ -93,7 +93,12 @@ export const getFactoryMarketDataV2 = (llamalend) => __awaiter(void 0, void 0, v
|
|
|
93
93
|
borrowed_tokens.push(marketData[4].toLowerCase());
|
|
94
94
|
monetary_policies.push(marketData[6].toLowerCase());
|
|
95
95
|
names.push(''); // new factory does not give names, it's generated at the market creation level
|
|
96
|
-
|
|
96
|
+
}
|
|
97
|
+
// Fetch gauges for non-mainnet chains. Mainnet will use the new approach of fetching gauges from the new factory.
|
|
98
|
+
const gaugeFactoryAddress = llamalend.constants.ALIASES.gauge_factory;
|
|
99
|
+
if (llamalend.chainId !== 1 && gaugeFactoryAddress && gaugeFactoryAddress !== llamalend.constants.ZERO_ADDRESS) {
|
|
100
|
+
const gaugeFactory = llamalend.contracts[gaugeFactoryAddress];
|
|
101
|
+
(yield llamalend.multicallProvider.all(vaults.map((vault) => createCall(gaugeFactory, "get_gauge_from_lp_token", [vault])))).forEach((gauge, i) => { gauges[i] = gauge.toLowerCase(); });
|
|
97
102
|
}
|
|
98
103
|
return {
|
|
99
104
|
names,
|
|
@@ -15,7 +15,7 @@ import { WEEK } from "../../../constants/utils";
|
|
|
15
15
|
export class VaultModule {
|
|
16
16
|
constructor(market) {
|
|
17
17
|
this._calcCrvApr = (...args_1) => __awaiter(this, [...args_1], void 0, function* (futureWorkingSupplyBN = null) {
|
|
18
|
-
const totalLiquidityUSD = yield this.vaultTotalLiquidity();
|
|
18
|
+
const totalLiquidityUSD = yield this.vaultTotalLiquidity(false);
|
|
19
19
|
if (Number(totalLiquidityUSD) === 0)
|
|
20
20
|
return [0, 0];
|
|
21
21
|
let inflationRateBN, workingSupplyBN, totalSupplyBN;
|
|
@@ -415,7 +415,7 @@ export class VaultModule {
|
|
|
415
415
|
}
|
|
416
416
|
vaultTotalLiquidity() {
|
|
417
417
|
return __awaiter(this, arguments, void 0, function* (useAPI = true) {
|
|
418
|
-
const { totalAssets } = yield this.market.stats.capAndAvailable(
|
|
418
|
+
const { totalAssets } = yield this.market.stats.capAndAvailable(false, useAPI);
|
|
419
419
|
const price = yield _getUsdRate.call(this.llamalend, this.market.addresses.borrowed_token);
|
|
420
420
|
return BN(totalAssets).times(price).toFixed(6);
|
|
421
421
|
});
|
package/package.json
CHANGED
|
@@ -95,7 +95,7 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
|
|
|
95
95
|
const collateral_tokens: string[] = [];
|
|
96
96
|
const borrowed_tokens: string[] = [];
|
|
97
97
|
const monetary_policies: string[] = [];
|
|
98
|
-
const gauges: string[] =
|
|
98
|
+
const gauges: string[] = new Array(Number(markets_count)).fill(llamalend.constants.ZERO_ADDRESS);
|
|
99
99
|
|
|
100
100
|
for (let i = 0; i < markets_count; i++) {
|
|
101
101
|
const marketData = res[i] as any;
|
|
@@ -107,7 +107,15 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
|
|
|
107
107
|
borrowed_tokens.push(marketData[4].toLowerCase());
|
|
108
108
|
monetary_policies.push(marketData[6].toLowerCase());
|
|
109
109
|
names.push(''); // new factory does not give names, it's generated at the market creation level
|
|
110
|
-
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Fetch gauges for non-mainnet chains. Mainnet will use the new approach of fetching gauges from the new factory.
|
|
113
|
+
const gaugeFactoryAddress = llamalend.constants.ALIASES.gauge_factory;
|
|
114
|
+
if (llamalend.chainId !== 1 && gaugeFactoryAddress && gaugeFactoryAddress !== llamalend.constants.ZERO_ADDRESS) {
|
|
115
|
+
const gaugeFactory = llamalend.contracts[gaugeFactoryAddress];
|
|
116
|
+
(await llamalend.multicallProvider.all(
|
|
117
|
+
vaults.map((vault: string) => createCall(gaugeFactory, "get_gauge_from_lp_token", [vault]))
|
|
118
|
+
) as string[]).forEach((gauge, i) => { gauges[i] = gauge.toLowerCase(); });
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
return {
|
|
@@ -289,14 +289,15 @@ export class VaultModule {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
public async vaultTotalLiquidity(useAPI = true): Promise<string> {
|
|
292
|
-
const { totalAssets } = await this.market.stats.capAndAvailable(
|
|
292
|
+
const { totalAssets } = await this.market.stats.capAndAvailable(false, useAPI);
|
|
293
293
|
const price = await _getUsdRate.call(this.llamalend, this.market.addresses.borrowed_token);
|
|
294
294
|
|
|
295
295
|
return BN(totalAssets).times(price).toFixed(6)
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
private _calcCrvApr = async (futureWorkingSupplyBN: BigNumber | null = null): Promise<[baseApy: number, boostedApy: number]> => {
|
|
299
|
-
const totalLiquidityUSD = await this.vaultTotalLiquidity();
|
|
299
|
+
const totalLiquidityUSD = await this.vaultTotalLiquidity(false);
|
|
300
|
+
|
|
300
301
|
if (Number(totalLiquidityUSD) === 0) return [0, 0];
|
|
301
302
|
|
|
302
303
|
let inflationRateBN, workingSupplyBN, totalSupplyBN;
|