mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 22:43:12 +08:00
migrate some types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { gql, request } from "graphql-request";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
|
||||
const query = gql`
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ethers } from "ethers";
|
||||
import { providers } from "../utils/ethers";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
|
||||
const subgraphUrl = "https://api.thegraph.com/subgraphs/name/picodes/borrow";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gql } from "graphql-request";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
import {
|
||||
Account,
|
||||
borrowBalanceUnderlying,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gql } from "graphql-request";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
import {
|
||||
Account,
|
||||
borrowBalanceUnderlying,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gql } from "graphql-request";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
|
||||
const subgraphUrl = "https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gql, request } from "graphql-request";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
|
||||
const subgraphUrl = "https://api.thegraph.com/subgraphs/name/liquity/liquity";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ethers } from "ethers";
|
||||
import { providers } from "../utils/ethers";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
const sdk = require("@defillama/sdk");
|
||||
|
||||
// all maker contracts: https://chainlog.makerdao.com/api/mainnet/active.json
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PublicKey, Connection } from "@solana/web3.js";
|
||||
import { SolendMarket, SolendObligation, parseObligation } from "@solendprotocol/solend-sdk";
|
||||
import { BigNumber } from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
|
||||
const endpoint = process.env.SOLANA_RPC || "https://solana-api.projectserum.com/"; // or "https://api.mainnet-beta.solana.com"
|
||||
const connection = new Connection(endpoint, "confirmed");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gql } from "graphql-request";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
|
||||
const subgraphUrl = "https://api.thegraph.com/subgraphs/name/traderjoe-xyz/lending";
|
||||
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
import axios from "axios";
|
||||
import { Liq } from "./types";
|
||||
|
||||
export const TOTAL_BINS = 20;
|
||||
|
||||
export interface Liq {
|
||||
owner: string;
|
||||
liqPrice: number;
|
||||
collateral: string;
|
||||
collateralAmount: string;
|
||||
extra?: {
|
||||
displayName?: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Bins {
|
||||
[token: string]: {
|
||||
bins: {
|
||||
|
||||
@@ -2,6 +2,7 @@ import axios from "axios";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { gql } from "graphql-request";
|
||||
import { getPagedGql } from "./gql";
|
||||
import { Prices } from "./types";
|
||||
|
||||
export const bignum = (value: string | number) => new BigNumber(value);
|
||||
|
||||
@@ -32,9 +33,6 @@ export type Account = {
|
||||
hasBorrowed: boolean;
|
||||
};
|
||||
|
||||
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.get("https://coins.llama.fi/prices/current/" + tokens.join(","))).data.coins as Prices;
|
||||
|
||||
13
liquidations/utils/types.ts
Normal file
13
liquidations/utils/types.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export type Price = { decimals: number; price: number; symbol: string; timestamp: number; confidence: number };
|
||||
export type Prices = { [address: string]: Price };
|
||||
|
||||
export interface Liq {
|
||||
owner: string;
|
||||
liqPrice: number;
|
||||
collateral: string;
|
||||
collateralAmount: string;
|
||||
extra?: {
|
||||
displayName?: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gql } from "graphql-request";
|
||||
import { getPagedGql } from "../utils/gql";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { Liq } from "../utils/binResults";
|
||||
import { Liq } from "../utils/types";
|
||||
import {
|
||||
Account,
|
||||
borrowBalanceUnderlying,
|
||||
|
||||
Reference in New Issue
Block a user