Merge pull request #4076 from 0xStrobe/chore-use-new-price-api

[liquidations] use new price api
This commit is contained in:
strobie
2022-09-29 19:46:11 +02:00
committed by GitHub
2 changed files with 4 additions and 13 deletions

View File

@@ -26,11 +26,8 @@ export interface Bins {
export async function binResults(liqs: Liq[]) {
const tokens = new Set<string>();
liqs.map((liq) => tokens.add(liq.collateral.toLowerCase()));
const prices = (
await axios.post("https://coins.llama.fi/prices", {
coins: Array.from(tokens),
})
).data.coins as {
const prices = (await axios.get("https://coins.llama.fi/prices/current/" + Array.from(tokens).join(","))).data
.coins as {
[address: string]: { decimals: number; price: number; symbol: string; timestamp: number };
};
console.log(prices);

View File

@@ -32,18 +32,12 @@ export type Account = {
hasBorrowed: boolean;
};
export type Price = { decimals: number; price: number; symbol: string; timestamp: number };
export type Price = { decimals: number; price: number; symbol: string; timestamp: number; confidence: number };
export type Prices = { [address: string]: Price };
export const getUnderlyingPrices = async (markets: Market[], chainPrefix: string): Promise<Prices> => {
const tokens = markets.map((m) => m.underlyingAddress).map((a) => chainPrefix + a.toLowerCase());
const prices = (
await axios.post("https://coins.llama.fi/prices", {
coins: Array.from(tokens),
})
).data.coins as {
[address: string]: { decimals: number; price: number; symbol: string; timestamp: number };
};
const prices = (await axios.get("https://coins.llama.fi/prices/current/" + tokens.join(","))).data.coins as Prices;
return prices;
};