Skip to content

Commit

Permalink
feat: new sdk method to get usd prices
Browse files Browse the repository at this point in the history
  • Loading branch information
odcey committed Feb 29, 2024
1 parent b31b467 commit d9648ca
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,31 @@ export class Squid extends TokensChains {
chainId,
}: {
tokenAddress: string;
chainId: string | number;
}) {
const response = await this.httpInstance.axios.get("/v2/token-price", {
params: { tokenAddress, chainId },
chainId: string;
}): Promise<number> {
const response = await this.httpInstance.axios.get("/v2/tokens", {
params: { address: tokenAddress, chainId, usdPrice: true },
});

return response.data.token.usdPrice;
}

public async getAllTokensWithPrice(): Promise<Token[]> {
const response = await this.httpInstance.axios.get("/v2/tokens", {
params: { usdPrice: true },
});

return response.data.tokens;
}

public async getAllTokensWithPriceForChain({ chainId }: { chainId: string }): Promise<Token[]> {
const response = await this.httpInstance.axios.get("/v2/tokens", {
params: { chainId, usdPrice: true },
});

return response.data.tokens;
}

public async getFromAmount({
fromToken,
toAmount,
Expand Down

0 comments on commit d9648ca

Please sign in to comment.