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:
12
package-lock.json
generated
12
package-lock.json
generated
@@ -785,9 +785,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@defillama/sdk": {
|
||||
"version": "4.0.57",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.57.tgz",
|
||||
"integrity": "sha512-20jdEUFqFCp/DJljUJczuTYVYjdq7xo+9B/FhAiEkkPI4t5fh1+dVKmLM765kEOYitlPGKZrnvFmQRLlTNW6sQ==",
|
||||
"version": "4.0.60",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.60.tgz",
|
||||
"integrity": "sha512-aAgn5yUZ27B8yOrS6cqv10y3mcySKD/fdvOGNBnAC++sLBcAvNQbPfDf4ArvZwQhcyqLpoPtOD2Qk6VfF4LYFw==",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.400.0",
|
||||
"@supercharge/promise-pool": "^2.1.0",
|
||||
@@ -5905,9 +5905,9 @@
|
||||
}
|
||||
},
|
||||
"@defillama/sdk": {
|
||||
"version": "4.0.57",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.57.tgz",
|
||||
"integrity": "sha512-20jdEUFqFCp/DJljUJczuTYVYjdq7xo+9B/FhAiEkkPI4t5fh1+dVKmLM765kEOYitlPGKZrnvFmQRLlTNW6sQ==",
|
||||
"version": "4.0.60",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.60.tgz",
|
||||
"integrity": "sha512-aAgn5yUZ27B8yOrS6cqv10y3mcySKD/fdvOGNBnAC++sLBcAvNQbPfDf4ArvZwQhcyqLpoPtOD2Qk6VfF4LYFw==",
|
||||
"requires": {
|
||||
"@aws-sdk/client-s3": "^3.400.0",
|
||||
"@supercharge/promise-pool": "^2.1.0",
|
||||
|
||||
@@ -1,14 +1,51 @@
|
||||
const { pool2s } = require("../helper/pool2");
|
||||
const { stakings } = require("../helper/staking");
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
|
||||
const cgpt = "0x9840652DC04fb9db2C43853633f0F62BE6f00f98";
|
||||
const stakingpool1 = "0x765a6ee976137801F2661c3644E1fde369A8ED18";
|
||||
const stakingpool2 = "0x62A402DEf6Ca37E9CA7a544bE34954748088CCEE";
|
||||
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const factory0 = '0xfb8c571f7152d2e092b0e650731c4d599cd514e1'
|
||||
const factory = '0xc263365D628568C23d61BDDa24C8EB27CEF4E917'
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: factory0,
|
||||
eventAbi: 'event PresalePoolCreated (address token, uint256 openTime, uint256 closeTime, address offeredCurrency, uint256 offeredCurrencyDecimals, uint256 offeredCurrencyRate, address wallet, address owner)',
|
||||
fromBlock: 30004999,
|
||||
})
|
||||
|
||||
const logs2 = await getLogs({
|
||||
api,
|
||||
target: factory,
|
||||
eventAbi: 'event PresalePoolCreated (address registedBy, address indexed token, address indexed pool, uint256 poolId)',
|
||||
fromBlock: 30004999,
|
||||
})
|
||||
const ownerTokens = []
|
||||
const poolTokenMapping = {}
|
||||
console.log(logs.length, logs2.length)
|
||||
logs.forEach(({ args: i}) => {
|
||||
const key = i.token+'-'+i.owner
|
||||
console.log(key, i.offeredCurrency)
|
||||
if (!poolTokenMapping[key]) poolTokenMapping[key] = []
|
||||
poolTokenMapping[key].push(i.offeredCurrency)
|
||||
})
|
||||
console.log(poolTokenMapping)
|
||||
logs2.forEach(({ args: i}) => {
|
||||
const key = i.token+'-'+i.registedBy
|
||||
if (!poolTokenMapping[key]) {
|
||||
console.log('missing mapping for ', key)
|
||||
return;
|
||||
}
|
||||
ownerTokens.push([poolTokenMapping[key], i.pool])
|
||||
})
|
||||
return api.sumTokens({ ownerTokens })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
bsc: {
|
||||
tvl: async () => ({}),
|
||||
tvl,
|
||||
staking: stakings([stakingpool1, stakingpool2], cgpt),
|
||||
},
|
||||
};
|
||||
@@ -1,49 +1,36 @@
|
||||
const {GraphQLClient, gql} = require('graphql-request');
|
||||
const {toUSDTBalances} = require("../helper/balances");
|
||||
const { queryContract } = require("../helper/chain/cosmos");
|
||||
const { transformDexBalances } = require("../helper/portedTokens");
|
||||
|
||||
const dexterSubgraphEndpoint = "https://api.core-1.dexter.zone/v1/graphql";
|
||||
const dexterVaultAddr = "persistence1k8re7jwz6rnnwrktnejdwkwnncte7ek7gt29gvnl3sdrg9mtnqkstujtpg";
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const contract = 'persistence1k8re7jwz6rnnwrktnejdwkwnncte7ek7gt29gvnl3sdrg9mtnqkstujtpg'
|
||||
const chain = api.chain
|
||||
const config = await queryContract({ chain, contract, data: { config: {} }, });
|
||||
let poolId = 1
|
||||
const data = []
|
||||
do {
|
||||
const { assets, pool_type } = await queryContract({ chain, contract, data: { get_pool_by_id: { pool_id: '' + poolId } }, })
|
||||
// if (pool_type.stable_swap) {
|
||||
assets.forEach(({ info: { native_token: { denom }}, amount }) => api.add(denom, amount))
|
||||
// } else {
|
||||
// data.push({
|
||||
// token0: assets[0].info.native_token.denom,
|
||||
// token0Bal: assets[0].amount,
|
||||
// token1: assets[1].info.native_token.denom,
|
||||
// token1Bal: assets[1].amount,
|
||||
// })
|
||||
// }
|
||||
poolId++
|
||||
} while (poolId < +config.next_pool_id)
|
||||
return transformDexBalances({ chain, data, balances: api.getBalances()})
|
||||
|
||||
const currentTvlOp = gql`
|
||||
query defillama_current_tvl($vault: String, $date: date) {
|
||||
tvl: pool_daily_closing_data_aggregate(where: {vault_address: {_eq: $vault}, date: {_eq: $date}}) {
|
||||
aggregate {
|
||||
sum {
|
||||
liquidity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
async function getTvlAtTime(timestamp) {
|
||||
const date = new Date(timestamp * 1000);
|
||||
const dateStr = `${date.getUTCFullYear()}-${date.getUTCMonth() + 1}-${date.getUTCDate()}`;
|
||||
|
||||
const graphQLClient = new GraphQLClient(dexterSubgraphEndpoint);
|
||||
const results = await graphQLClient.request(currentTvlOp, {
|
||||
"vault": dexterVaultAddr,
|
||||
"date": dateStr
|
||||
});
|
||||
|
||||
return results.tvl.aggregate.sum.liquidity;
|
||||
}
|
||||
|
||||
async function tvl(timestamp) {
|
||||
const currentTVL = await getTvlAtTime(timestamp);
|
||||
|
||||
// return the liquidity for prev day, if none exists for current day
|
||||
const liquidity = currentTVL ? currentTVL : await getTvlAtTime(timestamp - 86400);
|
||||
|
||||
return toUSDTBalances(liquidity);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
timetravel: true,
|
||||
misrepresentedTokens: true,
|
||||
timetravel: false,
|
||||
// misrepresentedTokens: true,
|
||||
methodology: `Counts the liquidity on all AMM pools`,
|
||||
start: 1679788800, // "2023-03-26" UTC
|
||||
persistence: {
|
||||
tvl
|
||||
}
|
||||
}; // node test.js projects/dexter/index.js
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const { getUniTVL } = require("../helper/unknownTokens");
|
||||
const { staking, stakingPricedLP } = require('../helper/staking');
|
||||
const { staking } = require('../helper/staking');
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
avax: {
|
||||
tvl: getUniTVL({ factory: '0xaC7B7EaC8310170109301034b8FdB75eCa4CC491', useDefaultCoreAssets: true, hasStablePools: true }),
|
||||
staking: stakingPricedLP("0xed1eE3f892fe8a13A9BE02F92E8FB7410AA84739", "0x3712871408a829C5cd4e86DA1f4CE727eFCD28F6", "avax", "0x2071a39da7450d68e4f4902774203df208860da2", "avalanche-2"),
|
||||
staking: staking("0xed1eE3f892fe8a13A9BE02F92E8FB7410AA84739", "0x3712871408a829C5cd4e86DA1f4CE727eFCD28F6"),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@ const endPoints = {
|
||||
sei: "https://sei-api.polkachu.com",
|
||||
aura: "https://lcd.aura.network",
|
||||
archway: "https://api.mainnet.archway.io",
|
||||
sifchain: "https://sifchain-api.polkachu.com",
|
||||
};
|
||||
|
||||
const chainSubpaths = {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
const { get } = require('./helper/http')
|
||||
const { endPoints } = require('./helper/chain/cosmos')
|
||||
|
||||
async function tvl() {
|
||||
// const getPoolsRes = await get('https://api.sifchain.finance/clp/getPools')
|
||||
const getPoolsRes = await get('https://sifchain-api.polkachu.com/clp/getPools')
|
||||
const getPoolsRes = await get(endPoints.sifchain + '/clp/getPools')
|
||||
|
||||
const total = getPoolsRes.result.pools
|
||||
.map(pool => +pool.native_asset_balance)
|
||||
.reduce((sum, current) => sum + current, 0)
|
||||
|
||||
return {
|
||||
sifchain: total * 2 / 1e18
|
||||
}
|
||||
return {
|
||||
sifchain: total * 2 / 1e18
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user