Skip to content

Commit

Permalink
Merge branch 'DefiLlama:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-magpie authored Jan 12, 2025
2 parents 99cc32c + cffdf1f commit b724a46
Show file tree
Hide file tree
Showing 120 changed files with 3,794 additions and 748 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"biggest-files": "find ./projects -name '*.js' -not -path './projects/helper/*' -not -path './projects/curve/*' -not -path './projects/sigmao/*' -exec du -sh {} \\; | sort -rh | head -n 100",
"check-bitcoin-duplicates": "node utils/scripts/checkBTCDupsv2.js",
"string-timestamp": "node utils/scripts/stringTimestamp.js",
"sort-chains": "node projects/helper/getChainList.js",
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
},
"author": "",
Expand Down
18 changes: 16 additions & 2 deletions projects/CreampanFinance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ const accounts = Object.values({
account3: 'cro1pduq0ga2ans0sspph6r5hcf77cqypz6de7n64y',
account4: 'cro1fncg0fsr8vt30qaqmzqxunnrkxr6a7xxkfpr7y',
account5: 'cro1hhfh6xaflg8zwhwvrs7sgur2pyfunjqeu8wsd6',
account6: 'cro1a2vawclcntewtjd5jfjf44dr6mdfdyg8xzfe5t',
account7: 'cro1wc43z84u8keas3ffw4ynapwe0hzfen3xx03dpd',
account8: 'cro1ujkwlnfnl3mmka4twqx07azxk6djlplddcn48h',
account9: 'cro16wzuj3a9tdqk9z3edx587athz2kk75gj2l6etk',
account10: 'cro1hfx8t4nldtfk5w6h6eherfts4gtelvcn0dypc3',
})

async function tvl(api) {
const data = await Promise.all(accounts.map(account => queryV1Beta1({ chain: 'cronos', url: `/staking/v1beta1/delegations/${account}`, })));
const factroy_contract_address = '0x66f5997b7810723aceeeb8a880846fc117081bd0';
const data2 = await Promise.all(accounts.map(account => queryV1Beta1({ chain: 'cronos', url: `/staking/v1beta1/delegators/${account}/unbonding_delegations`, })));
const factory_contract_address = '0x66f5997b7810723aceeeb8a880846fc117081bd0';
const factoryV2_contract_address = '0xfd3300b2441072b35554f1043c3d3a413fd5c219';
data.map(i => i.delegation_responses).flat().forEach(i => api.add(ADDRESSES.cronos.WCRO, i.balance.amount * 1e10))
return api.sumTokens({ owner: factroy_contract_address, tokens: [ADDRESSES.cronos.WCRO_1]})

for (let j = 0; j < accounts.length; j++) {
if (Number(data2[j].pagination.total) > 0) {
data2[j].unbonding_responses[0].entries.flat().forEach(i => api.add(ADDRESSES.cronos.WCRO, i.balance * 1e10))
}
}

return api.sumTokens({ owners: [factory_contract_address, factoryV2_contract_address], tokens: [ADDRESSES.cronos.WCRO_1] })
}

module.exports = {
Expand Down
3 changes: 3 additions & 0 deletions projects/Equalizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ module.exports = {
tvl: uniTvlExport("0xc6366EFD0AF1d09171fe0EBF32c7943BB310832a", "fantom", undefined, undefined, { hasStablePools: true, useDefaultCoreAssets: true, }),
staking: staking("0x8313f3551C4D3984FfbaDFb42f780D0c8763Ce94", "0x3Fd3A0c85B70754eFc07aC9Ac0cbBDCe664865A6"),
},
sonic: {
tvl: uniTvlExport("0xDDD9845Ba0D8f38d3045f804f67A1a8B9A528FcC", "fantom", undefined, undefined, { hasStablePools: true, useDefaultCoreAssets: true, stablePoolSymbol: 's-'}),
}
}
44 changes: 3 additions & 41 deletions projects/SwapX-v2/index.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,9 @@
const { transformDexBalances } = require("../helper/portedTokens");
const { getLogs } = require("../helper/cache/getLogs");

const SWAPX_V2_FACTORY = "0x05c1be79d3aC21Cc4B727eeD58C9B2fF757F5663"
const PAIR_CREATED_TOPIC_1 = "0xc4805696c66d7cf352fc1d6bb633ad5ee82f6cb577c453024b6e0eb8306c6fc9"; // keccak256 hash of the event signature
const PAIR_CREATED_EVENT_ABI_1 = "event PairCreated(address indexed token0, address indexed token1, bool stable, address pair, uint)";
const fromBlock = 1333667;
const erc20Abi = "erc20:balanceOf";

async function tvl(api) {
const getPairs = (logs) => {
return logs.map(log => ({
token0: log.token0,
token1: log.token1,
pair: log.pair
}));
}

const logs = getPairs(await getLogs({
api,
target: SWAPX_V2_FACTORY,
fromBlock,
topic: PAIR_CREATED_TOPIC_1,
onlyArgs: true,
eventAbi: PAIR_CREATED_EVENT_ABI_1
}));

const tok0Bals = await api.multiCall({ abi: erc20Abi, calls: logs.map(log => ({ target: log.token0, params: log.pair })) })
const tok1Bals = await api.multiCall({ abi: erc20Abi, calls: logs.map(log => ({ target: log.token1, params: log.pair })) })

return transformDexBalances({
chain: api.chain,
data: logs.map((log, i) => ({
token0: log.token0,
token0Bal: tok0Bals[i],
token1: log.token1,
token1Bal: tok1Bals[i],
}))
})
}
const { uniTvlExport } = require("../helper/calculateUniTvl");

module.exports = {
misrepresentedTokens: true,
sonic: {
tvl
tvl: uniTvlExport("0x05c1be79d3aC21Cc4B727eeD58C9B2fF757F5663", undefined, undefined, {
}, { useDefaultCoreAssets: true, hasStablePools: true, }),
}
};
43 changes: 18 additions & 25 deletions projects/ZTLN/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,31 @@ query MyQuery {
}
`;

async function getTvl() {
try {
const data = await request(endpoint, query);

const securities = data.securities || [];

let tokens = 0;
const currencyDecimal = 10 ** 18;

securities.forEach(security => {
security.secondaryInvestors.forEach(investor => {
const amt = parseFloat(investor.amount);
tokens += amt / currencyDecimal;
});
});
async function tvl(api) {
const data = await request(endpoint, query);

const price = 100.5;
const tvl = tokens * price;
const securities = data.securities || [];

// console.log("tvl", tvl);
return tvl;
} catch (error) {
console.error("Error fetching TVL:", error);
return 0;
}
let tokens = 0;
const currencyDecimal = 10 ** 18;

securities.forEach(security => {
security.secondaryInvestors.forEach(investor => {
const amt = parseFloat(investor.amount);
tokens += amt / currencyDecimal;
});
});

const price = 100.5;
const tvl = tokens * price
api.addUSDValue(tvl);
}

module.exports = {
timetravel: false,
misrepresentedTokens: true,
methodology: "The value in RWA held by the protocol",
ethereum: {
fetch: getTvl
tvl
},
fetch: getTvl
};
12 changes: 7 additions & 5 deletions projects/alexar/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { getConfig } = require('../helper/cache')
const { sumTokens } = require('../helper/sumTokens')

const blacklistedAssets = ['uaxl'];

const chainMapping = {
avax: 'avalanche',
cosmos: 'cosmoshub',
Expand All @@ -11,9 +9,12 @@ const chainMapping = {
};

const blackListChains = ['comdex', 'crescent'];
const chainListSupply = ['juno', 'cosmos', 'carbon', 'injective', 'kujira', 'osmosis', 'persistence', 'stargaze', 'secret', 'stargaze', 'umee', 'evmos', 'terra2'];
const chainListSupply = ['juno', 'cosmos', 'injective', 'kujira', 'osmosis', 'persistence', 'stargaze', 'secret', 'stargaze', 'umee', 'evmos', 'terra2'];
const chainListTotal = ['avax', 'bsc', 'moonbeam', 'polygon', 'fantom', 'arbitrum', 'aurora', 'celo', 'kava', 'mantle', 'ethereum', 'base'];

const blacklistedTokensChain = {
ethereum: ['0x946fb08103b400d1c79e07acCCDEf5cfd26cd374'], // KIP tvl is higher than the circulating supply
}

chainListSupply.concat(chainListTotal).forEach(chain => {
if (blackListChains.includes(chain)) {
Expand All @@ -25,6 +26,7 @@ chainListSupply.concat(chainListTotal).forEach(chain => {
const config = await getConfig('alexar', 'https://api.axelarscan.io/api/getTVL')
const tokensAndOwners = []
const owners = []
const blacklistedTokens = blacklistedTokensChain[chain] || []
const mappedChain = chainMapping[chain] || chain;
config.data.forEach(({ tvl: { [mappedChain]: assetTvl } = {} }) => {
if (!assetTvl) return;
Expand All @@ -42,8 +44,8 @@ chainListSupply.concat(chainListTotal).forEach(chain => {
}
})
if (tokensAndOwners.length > 0)
return api.sumTokens({ tokensAndOwners })
return sumTokens({ chain, owners })
return api.sumTokens({ tokensAndOwners, blacklistedTokens })
return sumTokens({ chain, owners, blacklistedTokens, })
}
});

Expand Down
47 changes: 45 additions & 2 deletions projects/alphafi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,52 @@ const ALPHAFI_BLUEFIN_TVL_IDS = [
token0Type: "0xd1b72982e40348d069bb1ff701e634c117bb5f741f44dff91e472d3b01461e55::stsui::STSUI",
token1Type: ADDRESSES.sui.SUI
},
{ // stsui usdc
poolID: "0x95f0543f861584f1a3c3129c46901d5c5cc1d44e77eb57aab63eec55cd128f29",
parentPoolID: "0x151d6959cb2a6d1a5b6cfec6d1eae690af0318e46e5fb3ec45dd4e3b67eebeda",
investorID: "0x65e4af88e543e41c410f969801d53e40acb23da7be811e4c61d05a7d7d235b3b",
token0Type: "0xd1b72982e40348d069bb1ff701e634c117bb5f741f44dff91e472d3b01461e55::stsui::STSUI",
token1Type: ADDRESSES.sui.USDC_CIRCLE
},
{ // alpha stsui
poolID: "0xd601c2d1f451a1493e8d071482272a83e6dafbcdb82b249ca5b3ac909c4138f3",
parentPoolID: "0xd4051b5dc76ca354e48813268aa79de38b274878ef6a9d274066ae5a47f46cc6",
investorID: "0x959f6df092073b23c0ad0278a9cf070b6779f2edc9b7124108207b4d7b4e94ca",
token0Type: "0xfe3afec26c59e874f3c1d60b8203cb3852d2bb2aa415df9548b8d688e6683f93::alpha::ALPHA",
token1Type: "0xd1b72982e40348d069bb1ff701e634c117bb5f741f44dff91e472d3b01461e55::stsui::STSUI"
},
{ // suiusdt usdc
poolID: "0x5b975bf7d0f0e3784a5b2db8f0a3e0b45cdcc31b39a222e680716a6ad7eba67f",
parentPoolID: "0x0bd95d012d60190a6713ae51f2d833b24ae70c5fb07fcfb41db40f25549878b1",
investorID: "0x23c073d557e4512f1811bd7c767047de13de14c59bb9607373613531250910b7",
token0Type: ADDRESSES.sui.suiUSDT,
token1Type: ADDRESSES.sui.USDC_CIRCLE
},

]

const ALPHAFI_BLUEFIN_AUTOBALANCE_TVL_IDS = [
{ //sui usdc
poolID: "0x1ec0aacf500624de90dd21478da12fca4726b3837e78993aee1c82f631e8364d",
parentPoolID: "0x3b585786b13af1d8ea067ab37101b6513a05d2f90cfe60e8b1d9e1b46a63c4fa",
investorID: "0xcf2a8bfaafd4b50f068826e3e4217925b4280836d8f182e3481c3725269c2a1f",
token0Type: ADDRESSES.sui.SUI,
token1Type: ADDRESSES.sui.USDC_CIRCLE
},
{ //usdt usdc
poolID: "0x65a167f16da65732fc71ec5b8714e5beb293e931d54820f1fea188bbcf09383d",
parentPoolID: "0x0321b68a0fca8c990710d26986ba433d06b351deba9384017cd6175f20466a8f",
investorID: "0x685c0569675bb46b838941568f1123c03eeef374dc4160c7d9b3abbc3b93f25c",
token0Type: ADDRESSES.sui.USDT,
token1Type: ADDRESSES.sui.USDC_CIRCLE
},
{ //suiUsdt Usdc
poolID: "0x8b68333ff71fa008bb2c8bc26d5989fba51cec27393172bb6bbfdbd360489542",
parentPoolID: "0x0bd95d012d60190a6713ae51f2d833b24ae70c5fb07fcfb41db40f25549878b1",
investorID: "0x07506ea66cb73fa60dbea5177c974ca6c98d7cd8ee2fae631af6e79f139f99ec",
token0Type: ADDRESSES.sui.suiUSDT,
token1Type: ADDRESSES.sui.USDC_CIRCLE
},
]
const ALPHAFI_NAVI_TVL_IDS = [
{
poolID: "0x643f84e0a33b19e2b511be46232610c6eb38e772931f582f019b8bbfb893ddb3",
Expand Down Expand Up @@ -413,7 +456,7 @@ async function addPoolTVL4(api, alphafiBucketPools){

async function tvl(api) {

await Promise.all([addPoolTVL(api, ALPHAFI_CETUS_TVL_IDS), addPoolTVL2(api, ALPHAFI_NAVI_TVL_IDS), addPoolTVL3(api, ALPHAFI_NAVI_LOOP_TVL_IDS), addPoolTVL4(api, ALPHAFI_BUCKET_TVL_IDS), addPoolTVL(api, ALPHAFI_BLUEFIN_TVL_IDS)])
await Promise.all([addPoolTVL(api, ALPHAFI_CETUS_TVL_IDS), addPoolTVL2(api, ALPHAFI_NAVI_TVL_IDS), addPoolTVL3(api, ALPHAFI_NAVI_LOOP_TVL_IDS), addPoolTVL4(api, ALPHAFI_BUCKET_TVL_IDS), addPoolTVL(api, ALPHAFI_BLUEFIN_TVL_IDS), addPoolTVL(api, ALPHAFI_BLUEFIN_AUTOBALANCE_TVL_IDS)]);

}
async function pool2(api) {
Expand Down
2 changes: 1 addition & 1 deletion projects/apwine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = {
doublecounted: true,
ethereum: {
tvl: tvl_from_registry('ethereum'),
staking: staking(veAPW, APW),
//staking: staking(veAPW, APW),
},
polygon: {
tvl: tvl_from_registry('polygon'),
Expand Down
5 changes: 5 additions & 0 deletions projects/aquadex-v3/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { uniV3Export } = require('../helper/uniswapV3')

module.exports = uniV3Export({
water: { factory: '0xc8F2534FF7c88EFeacF4Fdb0E81D87c6235C3bEA', fromBlock: 1, },
})
Loading

0 comments on commit b724a46

Please sign in to comment.