mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 16:53:02 +08:00
Merge pull request #4076 from 0xStrobe/chore-use-new-price-api
[liquidations] use new price api
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user