Skip to content

Commit

Permalink
Merge pull request #409 from curvefi/fix/curve-lite-constants
Browse files Browse the repository at this point in the history
feat: add nativeCurrencySymbol to _getCurveLiteNetworks
  • Loading branch information
amytsang authored Nov 12, 2024
2 parents dae4559 + 376774b commit 6d247ca
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@curvefi/api",
"version": "2.65.2",
"version": "2.65.3",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
1 change: 1 addition & 0 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export const _getCurveLiteNetworks = memoize(
rpcUrl: metadata.rpcUrl,
chainId: metadata.chainId,
explorerUrl: metadata.explorerBaseUrl,
nativeCurrencySymbol: metadata.nativeCurrencySymbol,
};
})
.filter((network): network is ICurveLiteNetwork => network !== null);
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export interface ICurveLiteNetwork {
name: string
rpcUrl: string
explorerUrl: string
nativeCurrencySymbol: string
}

export type TVoteType = "PARAMETER" | "OWNERSHIP"
Expand Down
8 changes: 0 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ export const _getRewardsFromApi = async (): Promise<IDict<IRewardFromApi[]>> =>

const _usdRatesCache: IDict<{ rate: number, time: number }> = {}
export const _getUsdRate = async (assetId: string): Promise<number> => {
if(curve.isLiteChain) {
throw Error('This method is not supported for the lite version')
}

if (curve.chainId === 1 && assetId.toLowerCase() === '0x8762db106b2c2a0bccb3a80d1ed41273552616e8') return 0; // RSR
const pricesFromApi = await _getUsdPricesFromApi();
if (assetId.toLowerCase() in pricesFromApi) return pricesFromApi[assetId.toLowerCase()];
Expand Down Expand Up @@ -515,10 +511,6 @@ export const _getUsdRate = async (assetId: string): Promise<number> => {
}

export const getUsdRate = async (coin: string): Promise<number> => {
if(curve.isLiteChain) {
throw Error('This method is not supported for the lite version')
}

const [coinAddress] = _getCoinAddressesNoCheck(coin);
return await _getUsdRate(coinAddress);
}
Expand Down

0 comments on commit 6d247ca

Please sign in to comment.