Skip to content

Commit 6316ff9

Browse files
Merge branch 'master' of github.com:curvefi/curve-js into fix/init
2 parents 9d500df + fa5fd40 commit 6316ff9

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@curvefi/api",
3-
"version": "2.66.28",
3+
"version": "2.66.30",
44
"description": "JavaScript library for curve.finance",
55
"main": "lib/index.js",
66
"author": "Macket",

src/cached.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ export const _getPoolsFromApi =
2727
return poolsDict[poolType]
2828
}
2929

30-
export const _getAllPoolsFromApi = async (network: INetworkName, isLiteChain = false): Promise<IExtendedPoolDataFromApi[]> => {
30+
export const _getAllPoolsFromApi = async (network: INetworkName, isLiteChain: boolean): Promise<IExtendedPoolDataFromApi[]> => {
3131
const {poolLists} = await _getCachedData(network, isLiteChain);
3232
return poolLists
3333
}
3434

35-
export const _getUsdPricesFromApi = async (network:INetworkName): Promise<IDict<number>> => {
36-
const {usdPrices} = await _getCachedData(network, false);
35+
export const _getUsdPricesFromApi = async (network:INetworkName, isLiteChain: boolean): Promise<IDict<number>> => {
36+
const {usdPrices} = await _getCachedData(network, isLiteChain);
3737
return usdPrices
3838
}
3939

40-
export const _getCrvApyFromApi = async (network:INetworkName): Promise<IDict<[number, number]>> => {
41-
const {crvApy} = await _getCachedData(network, false);
40+
export const _getCrvApyFromApi = async (network:INetworkName, isLiteChain: boolean): Promise<IDict<[number, number]>> => {
41+
const {crvApy} = await _getCachedData(network, isLiteChain);
4242
return crvApy
4343
}

src/pools/subClasses/statsPool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class StatsPool implements IStatsPool {
170170
poolType = this.pool.id.replace(/-\d+$/, '');
171171
poolType = poolType.replace(/-v2$/, '');
172172
}
173-
const poolsData = (await _getPoolsFromApi.call(curve, network, poolType as IPoolType)).poolData;
173+
const poolsData = (await _getPoolsFromApi.call(curve, network, poolType as IPoolType, curve.isLiteChain)).poolData;
174174

175175
try {
176176
const totalLiquidity = poolsData.filter((data) => data.address.toLowerCase() === this.pool.address.toLowerCase())[0].usdTotal;
@@ -244,7 +244,7 @@ export class StatsPool implements IStatsPool {
244244

245245
const isDisabledChain = [1313161554].includes(curve.chainId); // Disable Aurora
246246
if (useApi && !isDisabledChain) {
247-
const crvAPYs = await _getCrvApyFromApi(curve.constants.NETWORK_NAME);
247+
const crvAPYs = await _getCrvApyFromApi(curve.constants.NETWORK_NAME, curve.isLiteChain);
248248
const poolCrvApy = crvAPYs[this.pool.gauge.address] ?? [0, 0]; // new pools might be missing
249249
return [poolCrvApy[0], poolCrvApy[1]];
250250
}

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export function getPoolIdBySwapAddress(this: Curve, swapAddress: string): string
319319

320320
export async function _getRewardsFromApi(this: Curve): Promise<IDict<IRewardFromApi[]>> {
321321
const network = this.constants.NETWORK_NAME;
322-
const allTypesExtendedPoolData = await _getAllPoolsFromApi.call(this, network);
322+
const allTypesExtendedPoolData = await _getAllPoolsFromApi(network, this.isLiteChain);
323323
const rewardsDict: IDict<IRewardFromApi[]> = {};
324324

325325
for (const extendedPoolData of allTypesExtendedPoolData) {
@@ -337,7 +337,7 @@ export async function _getRewardsFromApi(this: Curve): Promise<IDict<IRewardFrom
337337
const _usdRatesCache: IDict<{ rate: number, time: number }> = {}
338338
export async function _getUsdRate(this: Curve, assetId: string): Promise<number> {
339339
if (this.chainId === 1 && assetId.toLowerCase() === '0x8762db106b2c2a0bccb3a80d1ed41273552616e8') return 0; // RSR
340-
const pricesFromApi = await _getUsdPricesFromApi(this.constants.NETWORK_NAME);
340+
const pricesFromApi = await _getUsdPricesFromApi(this.constants.NETWORK_NAME, this.isLiteChain);
341341
if (assetId.toLowerCase() in pricesFromApi) return pricesFromApi[assetId.toLowerCase()];
342342

343343
if (assetId === 'USD' || (this.chainId === 137 && (assetId.toLowerCase() === this.constants.COINS.am3crv.toLowerCase()))) return 1
@@ -573,7 +573,7 @@ export async function getNetworkConstants(this: Curve, chainId: IChainId | numbe
573573

574574
export async function getTVL(this: Curve, chainId = this.chainId): Promise<number> {
575575
const networkConstants = await getNetworkConstants.call(this, chainId);
576-
const allTypesExtendedPoolData = await _getAllPoolsFromApi.call(this, networkConstants.NAME);
576+
const allTypesExtendedPoolData = await _getAllPoolsFromApi(networkConstants.NAME, this.isLiteChain);
577577

578578
return allTypesExtendedPoolData.reduce((sum, data) => sum + (data.tvl ?? data.tvlAll ?? 0), 0)
579579
}

0 commit comments

Comments
 (0)