Skip to content

Commit

Permalink
Merge branch 'main' of github.com:symbiosis-finance/DefiLlama-Adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
allush committed Aug 15, 2024
2 parents db0f0bb + d17fba3 commit 38a9c8f
Show file tree
Hide file tree
Showing 291 changed files with 4,808 additions and 4,865 deletions.
1,894 changes: 1,009 additions & 885 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions projects/Astra/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { getUniTVL } = require('../helper/unknownTokens')

const FACTORY = "0x2b6852CeDEF193ece9814Ee99BE4A4Df7F463557" // This factory is on AirDAO Mainnet (Chain Id: 16718)

const dexTVL = getUniTVL({ factory: FACTORY, useDefaultCoreAssets: true, fetchBalances: true, })

module.exports = {
misrepresentedTokens: true,
methodology: `Uses factory(${FACTORY}) address to find and price Liquidity Pool pairs.`,
airdao: {
tvl: dexTVL
}
};
13 changes: 11 additions & 2 deletions projects/DigiFT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const sdk = require('@defillama/sdk');
//Polygon FeedPrice contract address
const DFeedPriceAddress = "0x7d4d68f18d1be3410ab8d827fb7ebc690f938d2d"
const tokenListAbi = "function getAllTokenRecords() view returns (tuple(uint256 chainId, address tokenAddress, uint64 tokenType)[])"

async function getTokenList(tokenAPI, chainId) {
return (await tokenAPI.call({
target: DFeedPriceAddress,
abi: tokenListAbi
})).filter(item => item[0] == chainId && item[2] == '1').map(item => item[1]);
}

module.exports = {
ethereum: {
tvl: async (api) => {
Expand All @@ -19,5 +19,14 @@ module.exports = {
api.addTokens(tokens, tokenSupplies)
return api.getBalances()
}
},
arbitrum: {
tvl: async (api) => {
const tokenAPI = new sdk.ChainApi({ chain: 'polygon', timestamp: api.timestamp, });
const tokens = await getTokenList(tokenAPI, api.chainId)
const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: tokens})
api.addTokens(tokens, tokenSupplies)
return api.getBalances()
}
}
};
1 change: 0 additions & 1 deletion projects/GajFinance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ async function stakingAvax(timestamp, ethBlock, chainBlocks) {
}

module.exports = {
broken: 'Api is no longer reachable',
methodology: "TVL comes from NFT Farming, Jungle Pools, MasterChef and Vaults",
avax:{
staking: stakingAvax,
Expand Down
2 changes: 1 addition & 1 deletion projects/aark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function tvl(api) {
return api.sumTokens({ owner: VAULT_CONTRACT_ADDRESS, tokens: [
ADDRESSES.arbitrum.WETH,
ADDRESSES.arbitrum.USDC,
'0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F', //FRAX
ADDRESSES.arbitrum.FRAX, //FRAX
ADDRESSES.arbitrum.USDC_CIRCLE,
ADDRESSES.arbitrum.WSTETH,
ADDRESSES.arbitrum.DAI,
Expand Down
10 changes: 7 additions & 3 deletions projects/aave/v3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { aaveChainTvl } = require('../helper/aave');
const { aaveChainTvl, aaveExports } = require('../helper/aave');
const methodologies = require('../helper/methodologies');
const { mergeExports } = require('../helper/utils');

const v3params = ["0x770ef9f4fe897e59daCc474EF11238303F9552b6", undefined, ["0x69FA688f1Dc47d4B5d8029D5a35FB7a548310654"]]

Expand All @@ -24,13 +25,16 @@ function v3(chain) {
}
}

module.exports = {
module.exports = mergeExports({
methodology: methodologies.lendingMarket,
avax: v3("avax"),
...["optimism", "fantom", "harmony", "arbitrum", "polygon", "ethereum", "metis", "base", "xdai", "scroll", "bsc"].reduce((t, c) => ({ ...t, [c]: v3(c) }), {}),
hallmarks: [
[1659630089, "Start OP Rewards"],
[1650471689, "Start AVAX Rewards"]
],
};
}, {
// Lido pool
ethereum: aaveExports(undefined, "0x770ef9f4fe897e59daCc474EF11238303F9552b6", undefined, ["0xa3206d66cF94AA1e93B21a9D8d409d6375309F4A"], { v3: true, }),
});
// node test.js projects/aave/index.js
20 changes: 19 additions & 1 deletion projects/aevo-xyz/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,25 @@ module.exports = {
'0x7809621a6D7e61E400853C64b61568aA773A28Ef', // Native USDC
'0x5c7Dd6cb73d93879E94F20d103804C495A10aE7e', // WETH
],
fetchCoValentTokens: true,
tokens: [
ADDRESSES.optimism.USDC,
ADDRESSES.optimism.USDT,
ADDRESSES.optimism.WETH_1,
ADDRESSES.optimism.USDC_CIRCLE
]
})
},
base: {
tvl: sumTokensExport({
owners: [
'0x6ee3907D1B9423584195979812379143B327fb48', // Native USDC
'0xA8bD0eCb10a83CC6E14FC5381f384DD3C0779e8B', // WETH
],
tokens: [
ADDRESSES.base.USDC,
ADDRESSES.base.USDbC,
ADDRESSES.base.WETH,
]
})
}
}
6 changes: 3 additions & 3 deletions projects/affine-defi-liquid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module.exports = {
ethereum: {
tvl: sumERC4626VaultsExport({
vaults: [
'0x0D53bc2BA508dFdf47084d511F13Bb2eb3f8317B',
'0x47657094e3AF11c47d5eF4D3598A1536B394EEc4',
'0xcbC632833687DacDcc7DfaC96F6c5989381f4B47',
'0xF0a949B935e367A94cDFe0F2A54892C2BC7b2131',
],
isOG4626: true,
}),
},
}
}
18 changes: 14 additions & 4 deletions projects/airpuff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ module.exports = {
tvl: async (api) => {
const KUSDC = {
vault: "0x4c18E80b801AA24066D8B1C6E65ee245497Cb741",
token: "0xa415021bC5c4C3b5B989116DC35Ae95D9C962c8D",
token: ADDRESSES.karak.USDC,
};

const KWETH = {
vault: "0x9a9631F7BEcE5C6E0aBA1f73f0e5796c534dc4db",
token: "0x4200000000000000000000000000000000000006",
token: ADDRESSES.optimism.WETH_1,
};

const wethLending = {
vault: "0xd6034F9147CF7528e857403Dea93bc45743295eb",
token: "0x4200000000000000000000000000000000000006",
token: ADDRESSES.optimism.WETH_1,
};

const usdcLending = {
vault: "0x475820E4bCE0E3d233Ad7f6A8c9DD1f66974c5d6",
token: "0xa415021bC5c4C3b5B989116DC35Ae95D9C962c8D",
token: ADDRESSES.karak.USDC,
};

const KarakUSDCBal = await api.call({ target: KUSDC.vault, abi: contractAbis.getTotalSupply });
Expand Down Expand Up @@ -222,8 +222,12 @@ module.exports = {
reStakingToken: "0xeA1A6307D9b18F8d1cbf1c3Dd6aad8416C06a221",
oracle: "0xb09cbB6Aa95A004F9aeE4349DF431aF5ad03ECe4",
};


tokensAndOwners.push([eETH.reStakingToken, eETH.vault]);



// leverage users
const ezETH = {
vault: "0x32a0ce2bDfc37eE606aB905b4f9fC286049A774f",
Expand Down Expand Up @@ -334,6 +338,11 @@ module.exports = {
pendleAddress: "0xb05cabcd99cf9a73b19805edefc5f67ca5d1895e",
};

const bptrswETH1x2 = {
vault: "0x76338fca82925Fe2Df2C4F2c6e9545247617C634",
pendleAddress: "0x7bAf258049cc8B9A78097723dc19a8b103D4098F"
};

//new 1x strats on pendle v2

//PT Tensorplex Staked TAO 27JUN2024 (PT-stTAO-...)
Expand Down Expand Up @@ -388,6 +397,7 @@ module.exports = {
bptzrsETH1x,
bptzUSDe1x,
bptrswETH1x,
bptrswETH1x2,
pTEzETHDEC30,
].map((i) => [i.pendleAddress, i.vault]);
tokensAndOwners.push(...tokensAndOwners2);
Expand Down
20 changes: 7 additions & 13 deletions projects/akronswap/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
const { getUniTVL } = require('../helper/unknownTokens');


const tvl = getUniTVL({ factory: '0xAf39606bec181887951Ab6912Ac7EA216Bd6E4B4', useDefaultCoreAssets: true, fetchBalances: true, })

module.exports = {
misrepresentedTokens: true,
ethereum:{
tvl: getUniTVL({ factory: '0x6624Ac5F9abFA36174511607860e81C8dB9e84E9', useDefaultCoreAssets: true, fetchBalances: true, }),
},
arbitrum:{
tvl: getUniTVL({ factory: '0x40Cbdf84475f8Dd7C9a9c665eDE551EeaaF21F8d', useDefaultCoreAssets: true, fetchBalances: true, }),
},
base:{
tvl: getUniTVL({ factory: '0xD2156Bb9ed200FE88705443BfFcA788BA8b205f6', useDefaultCoreAssets: true, fetchBalances: true, }),
},
bsc:{
tvl: getUniTVL({ factory: '0x40Cbdf84475f8Dd7C9a9c665eDE551EeaaF21F8d', useDefaultCoreAssets: true, fetchBalances: true, }),
},
ethereum: { tvl, },
arbitrum: { tvl, },
base: { tvl, },
bsc: { tvl, },
}
2 changes: 1 addition & 1 deletion projects/alcor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function eos() {
// Alcor
// https://wax.alcor.exchange
async function wax() {
const accounts = ["swap.alcor", "alcordexmain"];
const accounts = ["swap.alcor", "alcordexmain", "liquid.alcor"];
const tokens = [
["eosio.token", "WAX", "wax"],
["alien.worlds", "TLM", "alien-worlds"],
Expand Down
110 changes: 110 additions & 0 deletions projects/alexlab/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
const { call } = require('../helper/chain/stacks-api')
const { getCache, setCache } = require('../helper/cache')
const { sleep } = require('../helper/utils')
const sdk = require('@defillama/sdk')

const factory = 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01'

async function tvl(api) {
// https://docs.alexgo.io/developers/smart-contracts


// get simple weight pool data
const simpleWeightAMM = 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.simple-weight-pool-alex'
let { value: swPools } = await call({ target: simpleWeightAMM, abi: 'get-pools' })
swPools = swPools.map(i => i.value)
for (const { value: pool } of swPools) {
const inputArgs = ['token-x', 'token-y'].map(key => pool[key])
const { value: poolData } = await call({ target: simpleWeightAMM, abi: 'get-pool-details', inputArgs })
api.add(pool['token-x'].value, poolData['balance-x'].value)
api.add(pool['token-y'].value, poolData['balance-y'].value)
await sleep(2100)
}



// get fixed weight pool data
const fixedWeightAMM = 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.fixed-weight-pool-v1-01'
let { value: fwPools } = await call({ target: fixedWeightAMM, abi: 'get-pools' })
fwPools = fwPools.map(i => i.value)
for (const { value: pool } of fwPools) {
const inputArgs = ['token-x', 'token-y', 'weight-x', 'weight-y'].map(key => pool[key])
const { value: poolData } = await call({ target: fixedWeightAMM, abi: 'get-pool-details', inputArgs })
api.add(pool['token-x'].value, poolData['balance-x'].value)
api.add(pool['token-y'].value, poolData['balance-y'].value)
await sleep(2100)
}



// update cache for amm v2 pools & token metadata
const cache = await getCache('alex/ammv2', 'stacks')
if (!cache.pairData) cache.pairData = []
if (!cache.tokenMetadata) cache.tokenMetadata = {}
const currentPairCount = cache.pairData.length
let hasMorePairs = true
let i = currentPairCount + 1
do {
try {
const pairData = await call({ target: factory, abi: 'get-pool-details-by-id', inputArgs: [{ type: 'number', value: i }] })
if (!pairData.value?.factor) hasMorePairs = false
else
cache.pairData.push(pairData.value)
i++
await sleep(2100)
} catch (e) {
sdk.log('error fetching pair data', e)
hasMorePairs = false
}
} while (hasMorePairs)
let cacheNeedsUpdate = cache.pairData.length > currentPairCount
const tokenSet = new Set(cache.pairData.flatMap(pair => [pair['token-x'], pair['token-y']]).map(token => token.value)
.filter(token => !cache.tokenMetadata[token])
)
const tokensMissingMetadata = Array.from(tokenSet)
if (tokensMissingMetadata.length > 0) {
cacheNeedsUpdate = true
for (const token of tokensMissingMetadata) {
try {
const decimals = await call({ target: token, abi: 'get-decimals' })
const symbol = await call({ target: token, abi: 'get-symbol' })
let baseToken = {}
let baseDecimals = {}
let baseSymbol = {}
try {
baseDecimals = await call({ target: token, abi: 'get-base-decimals' })
baseToken = await call({ target: token, abi: 'get-base-token' })
if (typeof baseToken === 'string') baseToken = { value: baseToken }
if (baseToken.value) {
baseSymbol = await call({ target: baseToken.value, abi: 'get-symbol' })
}
} catch (e) {
// sdk.log('error fetching base token metadata', e)
}
cache.tokenMetadata[token] = { decimals: decimals.value, symbol: symbol.value, baseToken: baseToken.value, baseDecimals: baseDecimals.value, baseSymbol: baseSymbol.value }
await sleep(2100)
} catch (e) {
sdk.log('error fetching token metadata', e)
}
}
}

api.log('pair count', cache.pairData.length)
if (cacheNeedsUpdate)
await setCache('alex/ammv2', 'stacks', cache)



// add amm v2 tvl
for (const pair of cache.pairData) {
const { value: bals } = await call({ target: factory, abi: 'get-balances', inputArgs: [pair['token-x'], pair['token-y'], pair.factor] })
api.add(pair['token-x'].value, bals['balance-x'].value)
api.add(pair['token-y'].value, bals['balance-y'].value)
await sleep(600)
}
return api.getBalances()
}

module.exports = {
stacks: { tvl }
}
35 changes: 5 additions & 30 deletions projects/alexlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,16 @@ const { get } = require('../helper/http')
// https://stacks-node-api.blockstack.org/extended/v1/address/SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.alex-vault/balances
const ALEX_API = "https://api.alexlab.co/v1";

async function fetch() {
const url = `${ALEX_API}/pool_token_stats`;
const alexStatsResponse = await get(url)

const valueLockedMap = {};
let totalValueLocked = 0;
for (const pool of alexStatsResponse) {
let poolValue = 0;
const poolToken = pool.pool_token;

if (poolToken == "age000-governance-token") {
poolValue = pool.price * pool.reserved_balance;
} else {
poolValue = pool.price * pool.total_supply;
}
totalValueLocked += poolValue;
valueLockedMap[poolToken] = poolValue;
}

return { tether: totalValueLocked };
}

async function staking() {
const url = `${ALEX_API}/stats/tvl`;
const alexResponse = await get(url)
return { tether: alexResponse.reserve_pool_value };
}
const { getExports } = require('../helper/heroku-api')

// node test.js projects/alexlab/index.js
module.exports = {
misrepresentedTokens: true,
timetravel: false,
stacks: {
tvl: fetch,
staking,
},
methodology: "Alex Lab TVL is sum of tokens locked in ALEX platform.",
};
...getExports("alexlab", ['stacks']),
}

module.exports.stacks.staking = staking
Loading

0 comments on commit 38a9c8f

Please sign in to comment.