@curvefi/api 2.72.2 → 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.
@@ -16,6 +16,7 @@ export interface IPricesGauge {
16
16
  gauge_weight: string;
17
17
  gauge_relative_weight: number;
18
18
  gauge_type: string;
19
+ creation_date: string;
19
20
  }
20
21
  export declare const getGaugesOverview: () => Promise<IPricesGauge[]>;
21
22
  export declare const getPoolsFromPricesApi: (network: INetworkName, poolType: IPoolType) => Promise<IExtendedPoolDataFromApi>;
package/lib/prices-api.js CHANGED
@@ -45,15 +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, _b;
48
+ var _a;
49
49
  const { gauges } = yield _getGaugesOverview();
50
- const map = new Map();
50
+ const newestGaugeByPoolAddress = new Map();
51
51
  for (const gauge of gauges !== null && gauges !== void 0 ? gauges : []) {
52
- if (((_a = gauge.pool) === null || _a === void 0 ? void 0 : _a.chain) !== network || gauge.gauge_type !== "Liquidity")
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")
53
55
  continue;
54
- map.set(gauge.pool.address.toLowerCase(), ((_b = gauge.effective_address) !== null && _b !== void 0 ? _b : gauge.address).toLowerCase());
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);
55
61
  }
56
- return map;
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()]; }));
57
63
  });
58
64
  export const getGaugesOverview = () => __awaiter(void 0, void 0, void 0, function* () {
59
65
  const { gauges } = yield _getGaugesOverview();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.72.2",
3
+ "version": "2.72.3",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",