mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 16:53:02 +08:00
graph migration: part 1
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -886,9 +886,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@defillama/sdk": {
|
||||
"version": "5.0.61",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.61.tgz",
|
||||
"integrity": "sha512-t7nOMdpQ29y1eZmQothokRqsrfmGSTcu/ZHauvl/CvDEcUuWK+uNpdSAYG0cf93Z3XUXKH4eyRI7XLZcYR7/6w==",
|
||||
"version": "5.0.67",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-5.0.67.tgz",
|
||||
"integrity": "sha512-gOJACkDuPyNicL2zs0J93LkbDOkcviSaNQAvRH/wQkeXcdo7tHwN5YH59sFFE6Ge6gsCgcI0KnyuO6E0yjmo8g==",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.400.0",
|
||||
"@elastic/elasticsearch": "^8.13.1",
|
||||
|
||||
@@ -2,10 +2,26 @@ const sdk = require('@defillama/sdk')
|
||||
|
||||
const { staking } = require('../helper/staking')
|
||||
const { getUniqueAddresses } = require('../helper/utils')
|
||||
const { graphQuery } = require('../helper/http')
|
||||
|
||||
const config = {
|
||||
ethereum: { dpools: 'https://api.thegraph.com/subgraphs/name/bacon-labs/eighty-eight-mph', vPools: [
|
||||
ethereum: { dpools: [
|
||||
"0x19e10132841616ce4790920d5f94b8571f9b9341",
|
||||
"0x22e6b9a65163ce1225d1f65ef7942a979d093039",
|
||||
"0x23fa6b36e870ca5753853538d17c3ca7f5269e84",
|
||||
"0x2f3efd1a90a2336ab8fa1b9060380dc37361ca55",
|
||||
"0x303cb7ede0c3ad99ce017cdc3abacd65164ff486",
|
||||
"0x35966201a7724b952455b73a36c8846d8745218e",
|
||||
"0x374226dbaa3e44bf3923afb63f5fd83928b7e148",
|
||||
"0x3f5611f7762cc39fc11e10c864ae38526f650e9d",
|
||||
"0x6712baab01fa2dc7be6635746ec2da6f8bd73e71",
|
||||
"0x681aaa7cf3f7e1f110842f0149ba8a4af53ef2fd",
|
||||
"0x904f81eff3c35877865810cca9a63f2d9cb7d4dd",
|
||||
"0xb1abaac351e06d40441cf2cd97f6f0098e6473f2",
|
||||
"0xd4837145c7e13d580904e8431cfd481f9794fc41",
|
||||
"0xdc86ac6140026267e0873b27c8629efe748e7146",
|
||||
"0xe615e59353f70ca2424aa0f24f49c639b8e924d3",
|
||||
"0xe8c52367b81113ed32bb276184e521c2fbe9393a",
|
||||
], vPools: [
|
||||
"0x062214fbe3f15d217512deb14572eb01face0392",
|
||||
"0x085d70ca0dade4683d0f59d5a5b7d3298011b4de",
|
||||
"0x0f834c3601088d1b060c47737a2f5ce4ffa5ac1d",
|
||||
@@ -40,8 +56,36 @@ const config = {
|
||||
"0x8eb1b3ac29e0dcbd7f519c86f1eb76a3aea41b76",
|
||||
"0xc1f147db2b6a9c9fbf322fac3d1fbf8b8aaeec10"
|
||||
] },
|
||||
avax: { dpools: 'https://api.thegraph.com/subgraphs/name/88mphapp/88mph-avalanche' },
|
||||
fantom: { dpools: 'https://api.thegraph.com/subgraphs/name/88mphapp/88mph-fantom', vPools: [
|
||||
avax: { dpools: [
|
||||
"0x2252185532317932b1883b3429407296a2c69244",
|
||||
"0x336c38657837aa2b5fd21d41ea651b6d792291d9",
|
||||
"0x4f28fc2be45682d1be1d0f155f4a52d4509db629",
|
||||
"0x58e65f624c5ecf595824c96b3853ea8da2f9adf1",
|
||||
"0x747cdec7d885ca961baec11481cda651bf4d1004",
|
||||
"0xa78276c04d8d807feb8271fe123c1f94c08a414d",
|
||||
"0xbcd1571761c2f3d8e0ae93651753aa968e357425",
|
||||
"0xc7cbb403d1722ee3e4ae61f452dc36d71e8800de",
|
||||
"0xd1fea1b2dc4e0be1f5f16bacf1dfeb7fc3434b5f",
|
||||
"0xd9f46096801799f59f34c95e0b4df0f6a76bfcf3",
|
||||
"0xeb706249f3b4640839e64211336b2063a3cdfbb9",
|
||||
"0xf0ca068be757e61cdfa6314bf59f5243767f1bfd"
|
||||
] },
|
||||
fantom: { dpools: [
|
||||
"0x23fe5a2ba80ea2251843086ec000911cfc79c864",
|
||||
"0x2744b79c985ae0c6b81f1da8eed1a4c67eb4b732",
|
||||
"0x3cab1cb5a9b68350b39ddf7ce23518d609a8bc78",
|
||||
"0x7e4697f650934ea6743b8b0619fc2454db02405a",
|
||||
"0xa1857578cec558eaed9120739b0c533549bdcb61",
|
||||
"0xa78276c04d8d807feb8271fe123c1f94c08a414d",
|
||||
"0xbdf43e9c6cf68359deff9292098622643ede5ec3",
|
||||
"0xc0710b3564fd4768f912150d39d519b66f2952d4",
|
||||
"0xc7cbb403d1722ee3e4ae61f452dc36d71e8800de",
|
||||
"0xc80cc61910c6f8f47aadc69e40ab8d1b2fa2c4df",
|
||||
"0xc91c2255525e80630eee710e7c0637bce7d98978",
|
||||
"0xcb29ce2526ff5f80ad1536c6a1b13238d615b4b9",
|
||||
"0xd62f71937fca1c7c05da08cec4c451f12fc64964",
|
||||
"0xf7fb7f095c8d0f4ee8ffbd142fe0b311491b45f3"
|
||||
], vPools: [
|
||||
"0x3cab1cb5a9b68350b39ddf7ce23518d609a8bc78",
|
||||
"0xa1857578cec558eaed9120739b0c533549bdcb61",
|
||||
"0xa78276c04d8d807feb8271fe123c1f94c08a414d",
|
||||
@@ -57,26 +101,24 @@ const config = {
|
||||
"0x2744b79c985ae0c6b81f1da8eed1a4c67eb4b732",
|
||||
"0xc91c2255525e80630eee710e7c0637bce7d98978"
|
||||
] },
|
||||
polygon: { dpools: 'https://api.thegraph.com/subgraphs/name/88mphapp/88mph-polygon' },
|
||||
polygon: { dpools: [
|
||||
"0x0e99145166e2982bb67054a1e5d3a902fc4d2b59",
|
||||
"0x3933baac41f04d0ffa0977b0e879bc56482ad667",
|
||||
"0x3b79eb9675ed29554f57b719dc66a461a4c84970",
|
||||
"0x4f28fc2be45682d1be1d0f155f4a52d4509db629",
|
||||
"0xa78276c04d8d807feb8271fe123c1f94c08a414d",
|
||||
"0xf5ef24a27f35cbe8a2b0a954acf81d7064ce6b70"
|
||||
] },
|
||||
}
|
||||
|
||||
const dPoolQuery = `{
|
||||
dpools {
|
||||
id
|
||||
address
|
||||
}
|
||||
}`
|
||||
|
||||
const tvlExports = {};
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { dpools, vPools = [], } = config[chain]
|
||||
let { dpools: pools, vPools = [], } = config[chain]
|
||||
tvlExports[chain] = {
|
||||
tvl: async (api) => {
|
||||
const balances = {}
|
||||
|
||||
const logs = await graphQuery(dpools, dPoolQuery)
|
||||
let pools = logs.dpools.map(i => i.address)
|
||||
pools.push(...vPools)
|
||||
pools = getUniqueAddresses(pools)
|
||||
const tokens = await api.multiCall({ abi: 'address:stablecoin', calls: pools })
|
||||
|
||||
@@ -10,7 +10,6 @@ const aelin_data = {
|
||||
{ target: '0x2c0979b0de5f99c2bde1e698aeca13b55695951e', fromBlock: 13996006 },
|
||||
{ target: '0x5541da82549d732878c4104c9887c408790397af', fromBlock: 13846412 },
|
||||
],
|
||||
'graphUrl': 'https://api.thegraph.com/subgraphs/name/aelin-xyz/aelin',
|
||||
'AELIN_ETH_LP': '0x974d51fafc9013e42cbbb9465ea03fe097824bcc',
|
||||
'AELIN_ETH_staking': '0x944cb90082fc1416d4b551a21cfe6d7cc5447c80',
|
||||
'AELIN': '0xa9c125bf4c8bb26f299c00969532b66732b1f758'
|
||||
@@ -21,7 +20,6 @@ const aelin_data = {
|
||||
{ target: '0x87525307974a312AF13a78041F88B0BAe23ebb10', fromBlock: 1487918 },
|
||||
{ target: '0x914ffc8dc0678911aae77f51b8489d6e214da20f', fromBlock: 1971285 },
|
||||
],
|
||||
'graphUrl': 'https://api.thegraph.com/subgraphs/name/aelin-xyz/optimism',
|
||||
'AELIN': '0x61BAADcF22d2565B0F471b291C475db5555e0b76',
|
||||
'AELIN_staking': '0xfe757a40f3eda520845b339c698b321663986a4d',
|
||||
'AELIN_ETH_LP': '0x665d8D87ac09Bdbc1222B8B9E72Ddcb82f76B54A',
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { request, gql } = require('graphql-request');
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
const { cachedGraphQuery } = require('../helper/cache')
|
||||
|
||||
const graphs = {
|
||||
ethereum: "https://api.thegraph.com/subgraphs/name/aktionariat/brokerbot",
|
||||
@@ -8,11 +7,8 @@ const graphs = {
|
||||
|
||||
function tvlPaged(chain) {
|
||||
return async (api) => {
|
||||
const block = await api.getBlock()
|
||||
const size = 1000
|
||||
let lastId = ''
|
||||
let brokerbots
|
||||
let graphQueryPaged = gql`
|
||||
let graphQueryPaged = `
|
||||
query brokerbotQuery($lastId: String, $block: Int) {
|
||||
brokerbots(block: { number: $block } first:${size} where: {id_gt: $lastId totalValueLockedUSD_gt: 100}) {
|
||||
id
|
||||
@@ -21,14 +17,9 @@ function tvlPaged(chain) {
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
do {
|
||||
const res = await request(graphs[chain], graphQueryPaged, { lastId, block: block - 5000 });
|
||||
brokerbots = res.brokerbots
|
||||
const tokensAndOwners = brokerbots.map(i => ([[i.token.id, i.id], [i.base.id, i.id]])).flat()
|
||||
await sumTokens2({ tokensAndOwners, api })
|
||||
lastId = brokerbots[brokerbots.length - 1]?.id
|
||||
} while (brokerbots.length === size)
|
||||
const data = await cachedGraphQuery('aktionariat-brokerbot/' + chain, graphs[chain], graphQueryPaged, { useBlock: true, api, fetchById: true, })
|
||||
const ownerTokens = data.map(i => [[i.token.id, i.base.id], i.id])
|
||||
return api.sumTokens({ ownerTokens })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,81 +1,12 @@
|
||||
const { GraphQLClient, gql } = require('graphql-request')
|
||||
const { getBlock } = require('../helper/http')
|
||||
const sdk = require('@defillama/sdk')
|
||||
|
||||
|
||||
async function fetchData(block, balances, transform, borrowed = false) {
|
||||
const baseUrl = 'https://api.thegraph.com/subgraphs/name/atlendis';
|
||||
const urlPolygon = `${baseUrl}/atlendis-hosted-service-polygon`;
|
||||
const graphQLClient = new GraphQLClient(urlPolygon)
|
||||
|
||||
const query = gql`
|
||||
query get_tvl($block: Int) {
|
||||
poolStatuses (block: { number: $block }) {
|
||||
state
|
||||
pool {
|
||||
id
|
||||
identifier
|
||||
parameters {
|
||||
underlyingToken
|
||||
}
|
||||
}
|
||||
normalizedAvailableAmount
|
||||
normalizedBorrowedAmount
|
||||
adjustedPendingAmount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// pull data
|
||||
const data = await graphQLClient.request(query, {
|
||||
block: block - 50
|
||||
});
|
||||
|
||||
// calculate TVL
|
||||
const agEUR = 'polygon:0xe0b52e49357fd4daf2c15e02058dce6bc0057db4'.toLowerCase()
|
||||
if (!borrowed) {
|
||||
for (let i = 0; i < data.poolStatuses.length; i++) {
|
||||
let amount = parseInt(data.poolStatuses[i].normalizedAvailableAmount)
|
||||
let assetAddress = data.poolStatuses[i].pool.parameters.underlyingToken;
|
||||
|
||||
assetAddress = transform(assetAddress);
|
||||
if (assetAddress === agEUR) amount *= 1e12
|
||||
sdk.util.sumSingleBalance(balances, assetAddress, amount / 1e12)
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < data.poolStatuses.length; i++) {
|
||||
let amount = parseInt(data.poolStatuses[i].normalizedBorrowedAmount)
|
||||
+ parseInt(data.poolStatuses[i].adjustedPendingAmount);
|
||||
let assetAddress = data.poolStatuses[i].pool.parameters.underlyingToken;
|
||||
|
||||
assetAddress = transform(assetAddress);
|
||||
if (assetAddress === agEUR) amount *= 1e12
|
||||
sdk.util.sumSingleBalance(balances, assetAddress, amount / 1e12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function tvl(timestamp, _, chainBlocks) {
|
||||
const balances = {};
|
||||
const block = await getBlock(timestamp, 'polygon', chainBlocks)
|
||||
const transform = i => `polygon:${i}`;
|
||||
await fetchData(block, balances, transform);
|
||||
return balances;
|
||||
}
|
||||
|
||||
async function borrowed(timestamp, _, chainBlocks) {
|
||||
const balances = {};
|
||||
const transform = i => `polygon:${i}`;
|
||||
const block = await getBlock(timestamp, 'polygon', chainBlocks)
|
||||
await fetchData(block, balances, transform, true);
|
||||
return balances;
|
||||
}
|
||||
|
||||
const { sumTokensExport } = require('../helper/unwrapLPs');
|
||||
|
||||
module.exports = {
|
||||
polygon: {
|
||||
tvl,
|
||||
borrowed,
|
||||
polygon: {
|
||||
tvl: sumTokensExport({ owners: ['0xbc13e1B5DA083b10622Ff5B52c9cFa1912F10B1F', '0x2fA375961A0cB525dB0f00af4E081a806A8639Fd'], tokens: [
|
||||
'0x60D55F02A771d515e077c9C2403a1ef324885CeC',
|
||||
'0x1a13f4ca1d028320a707d99520abfefca3998b7f',
|
||||
'0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4',
|
||||
], }),
|
||||
borrowed: () => ({}),
|
||||
}
|
||||
};
|
||||
@@ -1,92 +1,6 @@
|
||||
const { request, } = require("graphql-request");
|
||||
const { getBlock } = require('../helper/http')
|
||||
const sdk = require('@defillama/sdk')
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
|
||||
const graphEndpoints = {
|
||||
// ethereum: "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2",
|
||||
// "bsc": "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2-bsc",
|
||||
// //"heco": "https://q.hg.network/subgraphs/name/dodoex/heco",
|
||||
// "polygon": "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2-polygon",
|
||||
// "arbitrum": "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2-arbitrum",
|
||||
// "aurora": "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2-aurora",
|
||||
// "avax": "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2-avax",
|
||||
// "optimism": "https://api.thegraph.com/subgraphs/name/dodoex/dodoex-v2-optimism",
|
||||
// "base": "https://api.studio.thegraph.com/query/2860/dodoex_v2_base/v0.0.5",
|
||||
// "linea": "https://api.dodoex.io/graphql?chainId=59144&schemaName=dodoex&apikey=graphqldefiLlamadodoYzj5giof",
|
||||
// "scroll": "https://api.dodoex.io/graphql?chain=src&schemaName=dodoex&apikey=graphqldefiLlamadodoYzj5giof", // ChainId mapping error, so using chain
|
||||
// "manta": "https://api.dodoex.io/graphql?chainId=169&schemaName=dodoex&apikey=graphqldefiLlamadodoYzj5giof",
|
||||
// "mantle": "https://api.dodoex.io/graphql?chainId=5000&schemaName=dodoex&apikey=graphqldefiLlamadodoYzj5giof"
|
||||
}
|
||||
const graphQuery = `query get_pairs($lastId: ID, $block: Int!) {
|
||||
pairs(
|
||||
first: 1000
|
||||
block: {number: $block}
|
||||
where: {and: [{id_gt: $lastId}, {or: [{baseReserve_gt: 0}, {quoteReserve_gt: 0}]}]}
|
||||
) {
|
||||
id
|
||||
baseReserve
|
||||
quoteReserve
|
||||
baseToken {
|
||||
id
|
||||
symbol
|
||||
usdPrice
|
||||
decimals
|
||||
}
|
||||
quoteToken {
|
||||
id
|
||||
symbol
|
||||
usdPrice
|
||||
decimals
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
Object.keys(graphEndpoints).forEach(chain => {
|
||||
module.exports[chain] = {
|
||||
tvl: async (ts, _, chainBlocks) => {
|
||||
|
||||
const block = await getBlock(ts, chain, chainBlocks)
|
||||
let allPairs = []
|
||||
let lastId = ""
|
||||
let response;
|
||||
do {
|
||||
response = await request(
|
||||
graphEndpoints[chain],
|
||||
graphQuery,
|
||||
{ lastId, block: block - 500, }
|
||||
);
|
||||
allPairs = allPairs.concat(response.pairs)
|
||||
lastId = response.pairs[response.pairs.length - 1].id
|
||||
} while (response.pairs.length >= 1000);
|
||||
|
||||
const balances = {}
|
||||
const blacklist = [
|
||||
'0xd79d32a4722129a4d9b90d52d44bf5e91bed430c',
|
||||
'0xdb1e780db819333ea79c9744cc66c89fbf326ce8', // this token is destroyed
|
||||
'0xa88c5693c9c2549a75acd2b44f052f6a5568e918', // this token is destroyed
|
||||
'0x738076a6cb6c30d906bcb2e9ba0e0d9a58b3292e', // SRSB is absuredly priced
|
||||
'0x95e7c70b58790a1cbd377bc403cd7e9be7e0afb1', // YSL is absuredly priced
|
||||
'0x2b1e9ded77ff8ecd81f71ffc5751622e6f1291c3', // error querying balance
|
||||
'0x272c2CF847A49215A3A1D4bFf8760E503A06f880', // abnb LP mispriced
|
||||
'0xd4ca5c2aff1eefb0bea9e9eab16f88db2990c183', // XRPC
|
||||
].map(i => i.toLowerCase())
|
||||
|
||||
allPairs.forEach(pair => {
|
||||
if (pair.id.includes('-'))
|
||||
return null
|
||||
if (!blacklist.includes(pair.baseToken.id.toLowerCase()) && +pair.baseReserve > 1 && +pair.baseToken.usdPrice > 0)
|
||||
sdk.util.sumSingleBalance(balances, chain + ':' + pair.baseToken.id, pair.baseReserve * (10 ** pair.baseToken.decimals))
|
||||
if (!blacklist.includes(pair.quoteToken.id.toLowerCase()) && +pair.quoteReserve > 1 && +pair.quoteToken.usdPrice > 0)
|
||||
sdk.util.sumSingleBalance(balances, chain + ':' + pair.quoteToken.id, pair.quoteReserve * (10 ** pair.quoteToken.decimals))
|
||||
})
|
||||
|
||||
return balances
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const config = {
|
||||
ethereum: { dvmFactory: '0x72d220cE168C4f361dD4deE5D826a01AD8598f6C', dodoBirthFactory: '0x3a97247df274a17c59a3bd12735ea3fcdfb49950', fromBlock: 10613640, dspFactory: '0x6fddb76c93299d985f4d3fc7ac468f9a168577a4', dppFactory: ['0x5336ede8f971339f6c0e304c66ba16f1296a2fbe', '0xb5dc5e183c2acf02ab879a8569ab4edaf147d537', '0x6b4fa0bc61eddc928e0df9c7f01e407bfcd3e5ef'] },
|
||||
arbitrum: { dvmFactory: '0xDa4c4411c55B0785e501332354A036c04833B72b', fromBlock: 226578, dspFactory: '0xC8fE2440744dcd733246a4dB14093664DEFD5A53', dodoBirthFactory: '0xbcc3401e16c25eaf4d3fed632ce3288503883b1f', dppFactory: ['0xDdB13e6dd168E1a68DC2285Cb212078ae10394A9', '0xa6cf3d163358af376ec5e8b7cc5e102a05fde63d'] },
|
||||
|
||||
@@ -106,6 +106,7 @@ async function configPost(project, endpoint, data) {
|
||||
|
||||
async function cachedGraphQuery(project, endpoint, query, { api, useBlock = false, variables = {}, fetchById, safeBlockLimit, } = {}) {
|
||||
if (!project || !endpoint) throw new Error('Missing parameters')
|
||||
endpoint = sdk.graph.modifyEndpoint(endpoint)
|
||||
const key = 'config-cache'
|
||||
const cacheKey = getKey(key, project)
|
||||
if (!configCache[cacheKey]) configCache[cacheKey] = _cachedGraphQuery()
|
||||
@@ -137,6 +138,7 @@ async function cachedGraphQuery(project, endpoint, query, { api, useBlock = fals
|
||||
async function graphFetchById({ endpoint, query, params = {}, api, options: { useBlock = false, safeBlockLimit = 500 } = {} }) {
|
||||
if (useBlock && !params.block)
|
||||
params.block = await api.getBlock() - safeBlockLimit
|
||||
endpoint = sdk.graph.modifyEndpoint(endpoint)
|
||||
|
||||
let data = []
|
||||
let lastId = ""
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const { request, gql } = require("graphql-request");
|
||||
const { toUSDTBalances } = require('../helper/balances');
|
||||
const { blockQuery, getBlock, } = require('./http')
|
||||
const sdk = require('@defillama/sdk')
|
||||
|
||||
function getChainTvl(graphUrls, factoriesName = "uniswapFactories", tvlName = "totalLiquidityUSD", blockCatchupLimit = 500) {
|
||||
const graphQuery = gql`
|
||||
@@ -17,11 +18,12 @@ query get_tvl($block: Int) {
|
||||
await api.getBlock()
|
||||
const block = api.block
|
||||
let uniswapFactories
|
||||
const endpoint = sdk.graph.modifyEndpoint(graphUrls[chain])
|
||||
|
||||
if (!blockCatchupLimit) {
|
||||
uniswapFactories = (await request(graphUrls[chain], graphQuery, { block, }))[factoriesName];
|
||||
uniswapFactories = (await request(endpoint, graphQuery, { block, }))[factoriesName];
|
||||
} else {
|
||||
uniswapFactories = (await blockQuery(graphUrls[chain], graphQuery, { api, blockCatchupLimit, }))[factoriesName];
|
||||
uniswapFactories = (await blockQuery(endpoint, graphQuery, { api, blockCatchupLimit, }))[factoriesName];
|
||||
}
|
||||
|
||||
const usdTvl = Number(uniswapFactories[0][tvlName])
|
||||
|
||||
@@ -49,6 +49,8 @@ async function post(endpoint, body, options) {
|
||||
}
|
||||
|
||||
async function graphQuery(endpoint, graphQuery, params = {}, { api, timestamp, chain, chainBlocks, useBlock = false } = {}) {
|
||||
|
||||
endpoint = sdk.graph.modifyEndpoint(endpoint)
|
||||
if (typeof timestamp === "object" && timestamp.timestamp) timestamp = timestamp.timestamp
|
||||
if (api) {
|
||||
if (!timestamp) timestamp = api.timestamp
|
||||
@@ -63,6 +65,7 @@ async function graphQuery(endpoint, graphQuery, params = {}, { api, timestamp, c
|
||||
}
|
||||
|
||||
async function blockQuery(endpoint, query, { api, blockCatchupLimit = 500, }) {
|
||||
endpoint = sdk.graph.modifyEndpoint(endpoint)
|
||||
const graphQLClient = new GraphQLClient(endpoint)
|
||||
await api.getBlock()
|
||||
const block = api.block
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const { cachedGraphQuery } = require('../helper/cache')
|
||||
const { graphQuery, } = require('../helper/http')
|
||||
const { sleep, log } = require('../helper/utils')
|
||||
const v1Data = require('./v1Data.json')
|
||||
@@ -95,7 +96,7 @@ const getV1Calls = async (chain) => {
|
||||
};
|
||||
|
||||
const getV2Calls = async (chain) => {
|
||||
const { cohorts } = await graphQuery(v2EndPoints[chain], v2Query)
|
||||
const { cohorts } = await cachedGraphQuery('unifarm/'+chain, v2EndPoints[chain], v2Query)
|
||||
let calls = [];
|
||||
for (let i = 0; i < cohorts.length; i++) {
|
||||
const owner = cohorts[i].id
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { getChainTvl } = require('../helper/getUniSubgraphTvl');
|
||||
|
||||
const v1graph = getChainTvl({
|
||||
ethereum: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap'
|
||||
ethereum: 'ESnjgAG9NjfmHypk4Huu4PVvz55fUwpyrRqHF21thoLJ'
|
||||
}, "uniswaps", "totalLiquidityUSD")
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -2,7 +2,7 @@ const { getChainTvl } = require('../helper/getUniSubgraphTvl');
|
||||
const { getUniTVL } = require('../helper/unknownTokens');
|
||||
|
||||
const v2graph = getChainTvl({
|
||||
ethereum: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v2-dev'
|
||||
ethereum: 'A3Np3RQbaBA6oKJgiwDJeo5T3zrYfGHPWFYayMwtNDum'
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -3,14 +3,14 @@ const { cachedGraphQuery, configPost } = require('../helper/cache')
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
const graphs = {
|
||||
ethereum: "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3",
|
||||
optimism: "https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis",
|
||||
arbitrum: 'https://api.thegraph.com/subgraphs/name/ianlapham/arbitrum-dev',
|
||||
polygon: "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon",
|
||||
celo: "https://api.thegraph.com/subgraphs/name/jesse-sawa/uniswap-celo",
|
||||
bsc: "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-bsc",
|
||||
avax: "https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax",
|
||||
base: "https://api.studio.thegraph.com/query/48211/uniswap-v3-base/version/latest",
|
||||
ethereum: "5AXe97hGLfjgFAc6Xvg6uDpsD5hqpxrxcma9MoxG7j7h",
|
||||
optimism: "Cghf4LfVqPiFw6fp6Y5X5Ubc8UpmUhSfJL82zwiBFLaj",
|
||||
arbitrum: 'FbCGRftH4a3yZugY7TnbYgPJVEv2LvMT6oF1fxPe9aJM',
|
||||
polygon: "3hCPRGf4z88VC5rsBKU5AA9FBBq5nF3jbKJG7VZCbhjm",
|
||||
celo: "ESdrTJ3twMwWVoQ1hUE2u7PugEHX3QkenudD6aXCkDQ4",
|
||||
bsc: "F85MNzUGYqgSHSHRGgeVMNsdnW1KtZSVgFULumXRZTw2",
|
||||
// avax: "3Pwd3cqFKbqKAyaJfGUVmJJ7oYbFQLDa19iB27iMxebD",
|
||||
base: "43Hwfi3dJSoGpyas9VwNoDAv55yjgGrPpNSmbQZArzMG",
|
||||
}
|
||||
|
||||
const blacklists = {
|
||||
@@ -82,14 +82,15 @@ module.exports = {
|
||||
scroll: { factory: "0x70C62C8b8e801124A4Aa81ce07b637A3e83cb919", fromBlock: 1367, },
|
||||
blast: { factory: "0x792edade80af5fc680d96a2ed80a44247d2cf6fd", fromBlock: 400903, },
|
||||
linea: { factory: "0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9", fromBlock: 25247, },
|
||||
manta: {factory: "0x06D830e15081f65923674268121FF57Cc54e4e23", fromBlock: 1191705},
|
||||
taiko: {factory: "0x75FC67473A91335B5b8F8821277262a13B38c9b3", fromBlock: 961}
|
||||
manta: { factory: "0x06D830e15081f65923674268121FF57Cc54e4e23", fromBlock: 1191705 },
|
||||
avax: { factory: "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD", fromBlock: 27832972 },
|
||||
taiko: { factory: "0x75FC67473A91335B5b8F8821277262a13B38c9b3", fromBlock: 961 }
|
||||
|
||||
}),
|
||||
filecoin: { tvl: filecoinTvl },
|
||||
}
|
||||
|
||||
const chains = ['ethereum', 'arbitrum', 'optimism', 'polygon', 'bsc', 'avax', 'base']
|
||||
const chains = ['ethereum', 'arbitrum', 'optimism', 'polygon', 'bsc', 'base']
|
||||
|
||||
chains.forEach(chain => {
|
||||
module.exports[chain] = {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const { staking } = require('../helper/staking');
|
||||
const { cachedGraphQuery, getConfig } = require('../helper/cache')
|
||||
const sdk = require('@defillama/sdk')
|
||||
|
||||
const graphUrl = 'https://api.thegraph.com/subgraphs/name/yieldyak/reinvest-tracker'
|
||||
const graphUrl = sdk.graph.modifyEndpoint('7oSYYdK5RKmqggdzFyfUnojP6puDAj31C4ezDGrgVfk9')
|
||||
const graphQuery = `{ farms(first: 1000) { id }}`;
|
||||
|
||||
async function tvl(api) {
|
||||
|
||||
2
test.js
2
test.js
@@ -27,7 +27,7 @@ const currentCacheVersion = sdk.cache.currentVersion // load env for cache
|
||||
if (process.env.LLAMA_SANITIZE)
|
||||
Object.keys(process.env).forEach((key) => {
|
||||
if (key.endsWith('_RPC')) return;
|
||||
if (['TVL_LOCAL_CACHE_ROOT_FOLDER', 'LLAMA_DEBUG_MODE', ...ENV_KEYS].includes(key) || key.includes('SDK')) return;
|
||||
if (['TVL_LOCAL_CACHE_ROOT_FOLDER', 'LLAMA_DEBUG_MODE', 'GRAPH_API_KEY', ...ENV_KEYS].includes(key) || key.includes('SDK')) return;
|
||||
delete process.env[key]
|
||||
})
|
||||
process.env.SKIP_RPC_CHECK = 'true'
|
||||
|
||||
34
volume.md
34
volume.md
@@ -1,34 +0,0 @@
|
||||
#### 1inch
|
||||
https://api.thegraph.com/subgraphs/name/1inch-exchange/oneinch-liquidity-protocol-v2
|
||||
|
||||
#### Balancer
|
||||
https://api.thegraph.com/subgraphs/name/balancer-labs/balancer
|
||||
|
||||
#### Bancor
|
||||
https://thegraph.com/explorer/subgraph/blocklytics/bancor
|
||||
|
||||
#### Carthage
|
||||
https://thegraph.cndlchain.com/subgraphs/name/ianlapham/uniswap-v3-test
|
||||
|
||||
#### Curve
|
||||
https://www.curve.fi/raw-stats/ren-1440m.json //where ren is the pool name
|
||||
|
||||
#### Dodo
|
||||
https://thegraph.com/explorer/subgraph/dodoex/dodoex-v2
|
||||
|
||||
#### Dydx
|
||||
https://docs.dydx.exchange/#get-markets
|
||||
|
||||
#### Pancake Swap
|
||||
https://api.pancakeswap.finance/api/v1/stat
|
||||
|
||||
#### Champagne Swap
|
||||
https://api.thegraph.com/subgraphs/name/champagneswap/exchangev3
|
||||
|
||||
|
||||
#### Perp
|
||||
https://thegraph.com/explorer/subgraph/perpetual-protocol/perp-position-subgraph
|
||||
https://perp.gq/pairs
|
||||
|
||||
#### Uniswap
|
||||
https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2
|
||||
Reference in New Issue
Block a user