@curvefi/api 2.72.1 → 2.72.3
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/prices-api.d.ts +2 -0
- package/lib/prices-api.js +12 -5
- package/package.json +1 -1
package/lib/prices-api.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface IPricesGauge {
|
|
|
15
15
|
is_killed: boolean;
|
|
16
16
|
gauge_weight: string;
|
|
17
17
|
gauge_relative_weight: number;
|
|
18
|
+
gauge_type: string;
|
|
19
|
+
creation_date: string;
|
|
18
20
|
}
|
|
19
21
|
export declare const getGaugesOverview: () => Promise<IPricesGauge[]>;
|
|
20
22
|
export declare const getPoolsFromPricesApi: (network: INetworkName, poolType: IPoolType) => Promise<IExtendedPoolDataFromApi>;
|
package/lib/prices-api.js
CHANGED
|
@@ -45,14 +45,21 @@ const _getGaugesOverview = memoize(() => __awaiter(void 0, void 0, void 0, funct
|
|
|
45
45
|
maxAge: 5 * 60 * 1000,
|
|
46
46
|
});
|
|
47
47
|
const getGaugeAddressByPoolAddress = (network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
var _a
|
|
48
|
+
var _a;
|
|
49
49
|
const { gauges } = yield _getGaugesOverview();
|
|
50
|
-
const
|
|
50
|
+
const newestGaugeByPoolAddress = new Map();
|
|
51
51
|
for (const gauge of gauges !== null && gauges !== void 0 ? gauges : []) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// LMCallback gauges reward LlamaLend borrowers who use this pool's LP token as collateral.
|
|
53
|
+
// LPs can't stake in them, so they must not replace the pool's real gauge.
|
|
54
|
+
if (((_a = gauge.pool) === null || _a === void 0 ? void 0 : _a.chain) !== network || gauge.gauge_type === "LMCallback")
|
|
55
|
+
continue;
|
|
56
|
+
const poolAddress = gauge.pool.address.toLowerCase();
|
|
57
|
+
const current = newestGaugeByPoolAddress.get(poolAddress);
|
|
58
|
+
// A pool can have several gauges when one was redeployed, keep the newest instead of relying on API order.
|
|
59
|
+
if (!current || gauge.creation_date > current.creation_date)
|
|
60
|
+
newestGaugeByPoolAddress.set(poolAddress, gauge);
|
|
54
61
|
}
|
|
55
|
-
return
|
|
62
|
+
return new Map(Array.from(newestGaugeByPoolAddress, ([poolAddress, gauge]) => { var _a; return [poolAddress, ((_a = gauge.effective_address) !== null && _a !== void 0 ? _a : gauge.address).toLowerCase()]; }));
|
|
56
63
|
});
|
|
57
64
|
export const getGaugesOverview = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
65
|
const { gauges } = yield _getGaugesOverview();
|