mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 16:53:02 +08:00
fix broken adapters
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { request, gql } = require("graphql-request");
|
||||
const { toUSDTBalances } = require('../helper/balances');
|
||||
const { sumTokensExport } = require("../helper/unwrapLPs");
|
||||
|
||||
const graphUrl = 'https://api.thegraph.com/subgraphs/name/arrenv/behodler'
|
||||
const graphQuery = gql`
|
||||
@@ -28,9 +29,26 @@ async function tvl(timestamp, block) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
methodology: `ERC20 tokens deposited as liquidity on the AMM. You can see this on https://analytics.behodler.io/#/, pulling the data from the 'arrenv/behodler' subgraph`,
|
||||
ethereum:{
|
||||
tvl,
|
||||
tvl: sumTokensExport({
|
||||
owner: '0x1B8568FbB47708E9E9D31Ff303254f748805bF21',
|
||||
tokens: [
|
||||
'0xaFEf0965576070D1608F374cb14049EefaD218Ec',
|
||||
'0x4f5704D9D2cbCcAf11e70B34048d41A0d572993F',
|
||||
'0x0D8775F648430679A709E98d2b0Cb6250d2887EF',
|
||||
'0x319eAd06eb01E808C80c7eb9bd77C5d8d163AddB',
|
||||
'0xF047ee812b21050186f86106f6cABDfEc35366c6',
|
||||
'0x155ff1A85F440EE0A382eA949f24CE4E0b751c65',
|
||||
'0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2',
|
||||
'0x514910771AF9Ca656af840dff83E8264EcF986CA',
|
||||
'0x4575f41308EC1483f3d399aa9a2826d74Da13Deb',
|
||||
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||||
'0x93ED3FBe21207Ec2E8f2d3c3de6e058Cb73Bc04d',
|
||||
'0x42476F744292107e34519F9c357927074Ea3F75D',
|
||||
'0x890ff7533Ca0C44F33167FdEEeaB1cA7E690634F',
|
||||
],
|
||||
resolveLP: true,
|
||||
}),
|
||||
},
|
||||
}
|
||||
@@ -1,92 +1,33 @@
|
||||
const sdk = require("@defillama/sdk")
|
||||
const { post } = require('../helper/http')
|
||||
const { toUSDTBalances } = require('../helper/balances')
|
||||
const { sumTokens } = require("../helper/unwrapLPs")
|
||||
const { getChainTransform, getFixBalances } = require("../helper/portedTokens")
|
||||
const { sumTokens2 } = require("../helper/unwrapLPs")
|
||||
const abi = require("../mooniswap/abi.json")
|
||||
|
||||
const query = factory => `query emiswapFactories { emiswapFactories(where: {id: "${factory}"}) { id totalLiquidityUSD }}`
|
||||
const { staking } = require('../helper/staking')
|
||||
|
||||
const chainConfig = {
|
||||
ethereum: {
|
||||
factory: '0x1771dff85160768255F0a44D20965665806cBf48',
|
||||
url: 'https://api.thegraph.com/subgraphs/name/lombardi22/emiswap8'
|
||||
},
|
||||
kcc: {
|
||||
factory: '0x945316F2964ef5C6C84921b435a528DD1790E93a',
|
||||
url: 'https://thegraph.kcc.network/subgraphs/name/emiswap/emiswap1'
|
||||
},
|
||||
polygon: {
|
||||
factory: '0x23c1b313152e276e0CF61665dc3AC160b3c5aB19',
|
||||
url: 'https://api.thegraph.com/subgraphs/name/lombardi22/polygon',
|
||||
},
|
||||
shiden: {
|
||||
factory: '0x7449314B698f918E98c76279B5570613b243eECf',
|
||||
url: 'https://shiden-graph.emiswap.com/subgraphs/name/shiden',
|
||||
},
|
||||
avax: {
|
||||
factory: '0xaD6b9b31832A88Bb59dB4ACD820F8df2CfA84f0f',
|
||||
},
|
||||
astar: {
|
||||
factory: '0xb4BcA5955F26d2fA6B57842655d7aCf2380Ac854',
|
||||
},
|
||||
aurora: {
|
||||
factory: '0x979e5d41595263f6Dfec4F4D48419C555B80D95c',
|
||||
url: 'https://api.thegraph.com/subgraphs/name/lombardi22/aurora',
|
||||
},
|
||||
ethereum: { factory: '0x1771dff85160768255F0a44D20965665806cBf48', },
|
||||
kcc: { factory: '0x945316F2964ef5C6C84921b435a528DD1790E93a', },
|
||||
polygon: { factory: '0x23c1b313152e276e0CF61665dc3AC160b3c5aB19', },
|
||||
shiden: { factory: '0x7449314B698f918E98c76279B5570613b243eECf', },
|
||||
avax: { factory: '0xaD6b9b31832A88Bb59dB4ACD820F8df2CfA84f0f', },
|
||||
astar: { factory: '0xb4BcA5955F26d2fA6B57842655d7aCf2380Ac854', },
|
||||
aurora: { factory: '0x979e5d41595263f6Dfec4F4D48419C555B80D95c', },
|
||||
}
|
||||
|
||||
|
||||
const moduleExports = {}
|
||||
|
||||
Object.keys(chainConfig).forEach(chain => {
|
||||
const { factory, url } = chainConfig[chain]
|
||||
async function tvl() {
|
||||
const body = { query: query(factory), operationName: "emiswapFactories", variables: {} }
|
||||
const response = await post(url, body)
|
||||
return toUSDTBalances(response.data.emiswapFactories[0].totalLiquidityUSD)
|
||||
}
|
||||
|
||||
async function computeTvl(ts, _block, chainBlocks) {
|
||||
const balances = {}
|
||||
const block = chainBlocks[chain]
|
||||
const transformAddress = await getChainTransform(chain)
|
||||
const fixBalances = await getFixBalances(chain)
|
||||
|
||||
const getAllpools = (await sdk.api.abi.call({ abi: abi.getAllPools, target: factory, block, chain, })).output
|
||||
const getTokens = (await sdk.api.abi.multiCall({ abi: abi.getTokens, calls: getAllpools.map(pool => ({ target: pool })), block, chain, })).output
|
||||
const tokensAndOwners = []
|
||||
getTokens.forEach(({ output: tokens }, i) => {
|
||||
const owner = getAllpools[i]
|
||||
tokens.forEach(token => tokensAndOwners.push([token, owner]))
|
||||
})
|
||||
|
||||
await sumTokens(balances, tokensAndOwners, block, chain, transformAddress)
|
||||
fixBalances(balances)
|
||||
return balances
|
||||
}
|
||||
|
||||
moduleExports[chain] = { tvl: url ? tvl : computeTvl }
|
||||
})
|
||||
const eswToken = "0x5a75a093747b72a0e14056352751edf03518031d";
|
||||
const stakingPool = "0xe094E3E16e813a40E2d6cC4b89bfeAe0142044e1";
|
||||
|
||||
async function ethStaking(timestamp, block) {
|
||||
let balances = {};
|
||||
|
||||
let { output: balance } = await sdk.api.erc20.balanceOf({
|
||||
target: eswToken,
|
||||
owner: stakingPool,
|
||||
block,
|
||||
});
|
||||
sdk.util.sumSingleBalance(balances, eswToken, balance);
|
||||
|
||||
return balances;
|
||||
}
|
||||
|
||||
moduleExports.ethereum.staking = ethStaking
|
||||
|
||||
module.exports = {
|
||||
methodology: "ETH and KCC TVL are the total liquidity from the LPs according to the subgraph. Staking TVL would be ESW value in the staking pool.",
|
||||
...moduleExports
|
||||
};
|
||||
};
|
||||
|
||||
Object.keys(chainConfig).forEach(chain => {
|
||||
const { factory } = chainConfig[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const pools = await api.call({ target: factory, abi: abi.getAllPools, })
|
||||
const tokens = await api.multiCall({ calls: pools, abi: abi.getTokens, })
|
||||
return sumTokens2({ api, ownerTokens: pools.map((v, i) => [tokens[i], v]) })
|
||||
}
|
||||
}
|
||||
})
|
||||
module.exports.ethereum.staking = staking(stakingPool, eswToken)
|
||||
@@ -16,7 +16,7 @@ function uniV3Export(config) {
|
||||
const exports = {}
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
let { factory: target, fromBlock, topics, eventAbi, isAlgebra } = config[chain]
|
||||
let { factory: target, fromBlock, topics, eventAbi, isAlgebra, blacklistedTokens = [] } = config[chain]
|
||||
if (!topics) topics = isAlgebra ? algebraConfig.topics : uniswapConfig.topics
|
||||
if (!eventAbi) eventAbi = isAlgebra ? algebraConfig.eventAbi : uniswapConfig.eventAbi
|
||||
|
||||
@@ -31,7 +31,7 @@ function uniV3Export(config) {
|
||||
onlyArgs: true,
|
||||
})
|
||||
|
||||
return sumTokens2({ api, ownerTokens: logs.map(i => [[i.token0, i.token1], i.pool]), })
|
||||
return sumTokens2({ api, ownerTokens: logs.map(i => [[i.token0, i.token1], i.pool]), blacklistedTokens, })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const { uniV3Export } = require('../helper/uniswapV3')
|
||||
|
||||
module.exports = uniV3Export({
|
||||
bsc: { factory: '0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865', fromBlock: 26956207, },
|
||||
bsc: { factory: '0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865', fromBlock: 26956207, blacklistedTokens: [
|
||||
'0x860368babf32129c18306a70ce7db10c5b437072',
|
||||
'0xc476d3961f77645464acccce404eb17815a80878',
|
||||
] },
|
||||
ethereum: { factory: '0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865', fromBlock: 16950685, },
|
||||
})
|
||||
|
||||
@@ -38,5 +38,6 @@ module.exports = treasuryExports({
|
||||
],
|
||||
owners: [treasury, treasury1, treasury2, treasury3, vestingAddress],
|
||||
ownTokens: [GNO, LP, LP2],
|
||||
resolveUniV3: true,
|
||||
},
|
||||
})
|
||||
@@ -59,6 +59,10 @@ function isTransformable(obj, file) {
|
||||
function transform(obj, file) {
|
||||
const res = {}
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (['constructor', 'error'].includes(value.type)) {
|
||||
console.log('skipping element of type: ', value.type)
|
||||
continue;
|
||||
}
|
||||
if (!value.inputs) console.log('inputs missing', file)
|
||||
const iLen = value.inputs.length === 0
|
||||
const oLen = value.outputs?.length === 1
|
||||
|
||||
Reference in New Issue
Block a user