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
samster91 authored Feb 16, 2024
2 parents d603979 + 2eb5326 commit 18960a3
Show file tree
Hide file tree
Showing 1,137 changed files with 21,366 additions and 20,985 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commentResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
body = `The adapter at ${path} exports TVL:
\n \n ${file.substring(summaryIndex + 17).replaceAll('\n', '\n ')}`;
} else if (errorIndex != -1) {
body = `Error while running adapter at ${path}:
body = `Error while running adapter at ${path ?? ''}:
\n \n ${file.split(errorString)[1].replaceAll('\n', '\n ')}`;
} else
return;
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
npm ci
# npm update @defillama/sdk
# fail if package.json or package-lock.json is changed
FILES_MODIFIED=${{ steps.file_changes.outputs.files_modified }}
if [[ $FILES_MODIFIED == *"package.json"* || $FILES_MODIFIED == *"package-lock.json"* ]]; then
echo "------ ERROR ------ > Please revert changes to package.json / package-lock.json" > /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/output.txt
node ${{ github.workspace }}/.github/workflows/commentResult.js /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/output.txt "${{ github.repository_owner }}" "${{ github.event.repository.name }}" "${{ github.event.number }}"
exit 1
fi
for i in $(echo $RUN_FILES | tr -d '"[]' | tr "," "\n")
do
{
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Also, don't hesitate to send a message on [our discord](https://discord.defillam
> If you would like to add a `volume` adapter please submit the PR [here](https://github.com/DefiLlama/adapters)
> - If you would like to add a `liquidations` adapter, please refer to [this readme document](https://github.com/DefiLlama/DefiLlama-Adapters/tree/main/liquidations) for details.
1. Once your adapter has been merged, it takes time to show on the UI. If more than 24 hours have passed, please let us know in Discord.
2. Please enable "Allow edits by maintainers" while putting up the PR.
3. Sorry, We no longer accept fetch adapter for new projects, we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
1. PLEASE PLEASE **enable "Allow edits by maintainers" while putting up the PR.**
2. Once your adapter has been merged, it takes time to show on the UI. No need to notify us on Discord.
3. Sorry, We no longer accept fetch adapter for new projects (reason: https://github.com/DefiLlama/DefiLlama-Adapters/discussions/432), we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
4. **For updating listing info** It is a different repo, you can find your listing in this file: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/protocols/data2.ts, you can edit it there and put up a PR
5. Do not edit/push `package-lock.json` file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CI
6. No need to go to our discord and announce that you've created a PR, we monitor all PRs and will review it asap
Expand Down
9,793 changes: 2,300 additions & 7,493 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,35 @@
"tvl": "cd utils;npm i; cd ..; node utils/testInteractive",
"treasury": "cd utils;npm i; cd ..; node utils/testInteractive treasury",
"entities": "cd utils;npm i; cd ..; node utils/testInteractive entities",
"useTokenLabels": "node utils/scripts/useTokenLabels.js",
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
},
"author": "",
"license": "ISC",
"dependencies": {
"@defillama/sdk": "latest",
"@project-serum/anchor": "^0.25.0",
"@solana/web3.js": "^1.36.0",
"@solendprotocol/solend-sdk": "^0.6.2",
"@project-serum/anchor": "^0.26.0",
"@solana/web3.js": "^1.87.6",
"@solendprotocol/solend-sdk": "^0.4.3",
"@supercharge/promise-pool": "^2.1.0",
"axios": "^0.27.2",
"axios": "^1.6.5",
"bignumber.js": "^9.0.1",
"blakejs": "^1.2.1",
"bn.js": "^5.2.1",
"borsh": "^0.7.0",
"curve25519-js": "^0.0.4",
"dotenv": "^8.6.0",
"ethers": "^5.6.5",
"ethers": "^6.0.0",
"graphql": "^16.6.0",
"graphql-request": "^4.0.0",
"hi-base32": "^0.5.1",
"js-sha512": "^0.8.0",
"limiter": "2.1.0",
"miscreant": "^0.3.2",
"p-limit": "^3.1.0",
"starknet": "^4.17.1",
"starknet": "^5.24.3",
"tron-format-address": "^0.1.8",
"typescript": "^4.7.4"
"typescript": "^5.0.0"
},
"overrides": {
"ansi-regex": "5.0.1",
Expand Down
16 changes: 9 additions & 7 deletions projects/0vix/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const ADDRESSES = require('../helper/coreAssets.json')
const {compoundExports} = require('../helper/compound')
const {compoundExports2} = require('../helper/compound')

const master0vix = "0x8849f1a0cB6b5D6076aB150546EddEe193754F1C";
const oMATIC = "0xE554E874c9c60E45F1Debd479389C76230ae25A8";
const matic = ADDRESSES.polygon.WMATIC_2;
const chain = "polygon";

module.exports = {
hallmarks: [
[Math.floor(new Date('2023-04-28')/1e3), 'Protocol was hacked!'],
[Math.floor(new Date('2023-12-14')/1e3), 'Protocol was migrated to Keom!'],
],
polygon: compoundExports(master0vix, chain, oMATIC, matic),
polygon_zkevm: compoundExports("0x6EA32f626e3A5c41547235ebBdf861526e11f482", "polygon_zkevm", "0xee1727f5074e747716637e1776b7f7c7133f16b1", ADDRESSES.polygon_zkevm.WETH),
polygon: compoundExports2({ comptroller: master0vix, cether: oMATIC, }),
polygon_zkevm: {
tvl: () => ({}),
borrowed: () => ({}),
},
deadFrom: "2023-12-14",
};

delete module.exports.polygon.borrowed
module.exports.polygon.borrowed = () => ({})
20 changes: 7 additions & 13 deletions projects/0xDAO/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const sanitize = require("./sanitizeWeb3Response.js");

const { standardPoolInfoAbi, addFundsInMasterChef } = require('../helper/masterchef')
const sdk = require('@defillama/sdk')
const { default: BigNumber } = require('bignumber.js')

const shareValue = "uint256:getShareValue"
const xSCREAM = "0xe3D17C7e840ec140a7A51ACA351a482231760824"
Expand Down Expand Up @@ -41,7 +40,7 @@ async function tvl(time, ethBlock, chainBlocks) {
abi: shareValue
})
sdk.util.sumSingleBalance(balances, transform("0xe0654C8e6fd4D733349ac7E09f6f23DA256bF475"),
BigNumber(screamShare.output).times(balances[transform(xSCREAM)]).div(1e18).toFixed(0))
screamShare.output *balances[transform(xSCREAM)] /1e18)
delete balances[transform(xSCREAM)]

const creditShare = await sdk.api.abi.call({
Expand All @@ -50,14 +49,14 @@ async function tvl(time, ethBlock, chainBlocks) {
abi: shareValue
})
sdk.util.sumSingleBalance(balances, transform("0x77128dfdd0ac859b33f44050c6fa272f34872b5e"),
BigNumber(creditShare.output).times(balances[transform(xCREDIT)]).div(1e18).toFixed(0))
creditShare.output * balances[transform(xCREDIT)] / 1e18)
delete balances[transform(xCREDIT)]

const tarotShare = await sdk.api.abi.call({
...calldata,
target: xTAROT,
abi: shareTarot,
params: balances[transform(xTAROT)]
params: sdk.util.convertToBigInt(balances[transform(xTAROT)])
})
sdk.util.sumSingleBalance(balances, transform("0xc5e2b037d30a390e62180970b3aa4e91868764cd"),
tarotShare.output)
Expand Down Expand Up @@ -95,10 +94,10 @@ async function tvl(time, ethBlock, chainBlocks) {
...pool.poolData,
...reserveData,
};
const shareOfTotalSupply = new BigNumber(newPool.totalSupply).div(newPool.poolData.totalSupply).toFixed()
const shareOfTotalSupply = newPool.totalSupply / newPool.poolData.totalSupply
newPool.shareOfTotalSupply = shareOfTotalSupply;
let token0Reserve = new BigNumber(newPool.poolData.token0Reserve).times(shareOfTotalSupply).toFixed(0);
let token1Reserve = new BigNumber(newPool.poolData.token1Reserve).times(shareOfTotalSupply).toFixed(0);
let token0Reserve = newPool.poolData.token0Reserve * shareOfTotalSupply
let token1Reserve = newPool.poolData.token1Reserve * shareOfTotalSupply
if (isNaN(token0Reserve)) {
token0Reserve = "0"
}
Expand Down Expand Up @@ -145,12 +144,7 @@ async function tvl(time, ethBlock, chainBlocks) {
// Add TVL from pools to balances
const addBalance = (tokenAddress, amount) => {
const fantomTokenAddress = `fantom:${tokenAddress}`
const existingBalance = balances[fantomTokenAddress];
if (existingBalance) {
balances[fantomTokenAddress] = new BigNumber(existingBalance).plus(amount).toFixed(0)
} else {
balances[fantomTokenAddress] = amount;
}
sdk.util.sumSingleBalance(balances, fantomTokenAddress, amount)
}
pools.forEach(pool => {
const token0 = pool.poolData.token0Address;
Expand Down
7 changes: 7 additions & 0 deletions projects/10kdex/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { gmxExports } = require('../helper/gmx')

module.exports = {
scroll: {
tvl: gmxExports({ vault: '0x2C145157e59CfB69a4607643D178B015E6A3004a' })
},
};
11 changes: 11 additions & 0 deletions projects/1155Tech/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const ADDRESSES = require('../helper/coreAssets.json');
const { sumTokensExport } = require('../helper/unwrapLPs');
const MARKET_1155TECH_CONTRACT = '0x33b77fAf955Ed3eDAf939ae66C4D7a2D78bc30C6';

module.exports = {
methodology: 'Value of all Keys across all art markets is TVL in the protocol',
start: 7280880,
canto: {
tvl: sumTokensExport({ owner: MARKET_1155TECH_CONTRACT, tokens: [ADDRESSES.canto.NOTE] })
}
};
64 changes: 9 additions & 55 deletions projects/1beam/index.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,26 @@
const sdk = require('@defillama/sdk');
const { default: BigNumber } = require('bignumber.js');
const Abis = require('./abi.json');
const {getTokenId} = require('./utils')

const Contracts = {
moonbeam: {
pools: {
'ob3p': '0x04e274f709e1ae71aff4f994b4267143ec6a381a',
'ob3pbusd': '0x7e758319d46E0A053220e3728B3eE47a1979316a',
},
ignoredLps: ['0xe7a7dfb89f84a0cf850bcd399d0ec906ab232e9d'],
}
};

const poolTvl = async (chain, poolAddress, block) => {
const [balances, tokens] = await Promise.all([
sdk.api.abi.call({
target: poolAddress,
abi: Abis.getTokenBalances,
chain: chain,
block,
}),
sdk.api.abi.call({
target: poolAddress,
abi: Abis.getTokens,
chain: chain,
block,
}),
]);

const sum = {};

tokens.output.forEach((token, i) => {
if (
Contracts[chain].ignoredLps &&
Contracts[chain].ignoredLps.includes(token.toLowerCase())
) {
return;
}
const [symbol, decimals] = getTokenId(token.toLowerCase());
sum[symbol] = new BigNumber(balances.output[i]).div(new BigNumber(10).pow(decimals)).toNumber()
}

const moonbeamTvl = async (timestamp, ethBlock, chainBlocks, { api }) => {
const pools = Object.values(Contracts.moonbeam.pools)
const tokens = await api.multiCall({ abi: Abis.getTokens, calls: pools })
const bals = await api.multiCall({ abi: Abis.getTokenBalances, calls: pools })
tokens.forEach((token, i) => {
api.addTokens(token, bals[i])
});

return sum;
};

const moonbeamTvl = async (timestamp, ethBlock, chainBlocks) => {
let block = chainBlocks['moonbeam'];
const tvl = {};

for (let address of Object.values(Contracts.moonbeam.pools)) {
const balances = await poolTvl(
'moonbeam',
address,
block,
);

Object.entries(balances).forEach(([token, value]) => {
sdk.util.sumSingleBalance(tvl, token, value);
});
}

return tvl;
api.removeTokenBalance('0xe7a7dfb89f84a0cf850bcd399d0ec906ab232e9d')
};

module.exports = {
moonbeam: {
tvl: moonbeamTvl,
},

};
20 changes: 0 additions & 20 deletions projects/1beam/utils.js

This file was deleted.

2 changes: 1 addition & 1 deletion projects/1inch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Object.keys(config).forEach(chain => {
})
logs.forEach(i => ownerTokens.push([[i.token1, i.token2], i.mooniswap]))
}
return sumTokens2({ api, ownerTokens, blacklistedTokens, })
return sumTokens2({ api, ownerTokens, blacklistedTokens, sumChunkSize: 50, })
}
}
})
1 change: 0 additions & 1 deletion projects/1pulse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = {
misrepresentedTokens: true,
pulse: {
tvl: getUniTVL({
fetchBalances: true,
useDefaultCoreAssets: true,
factory: "0x17C335D22456c798D5A3D021583eDAcbD4Ef6444",
}),
Expand Down
52 changes: 2 additions & 50 deletions projects/2doge/index.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,21 @@
const sdk = require("@defillama/sdk");
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
const { stakingPricedLP } = require("../helper/staking");
const { pool2 } = require("../helper/pool2");

const tombTokenAddress = "0xDD057bCcB72982753266A903Feda154608e54468";
const tshareTokenAddress = "0x0c55339a139acd3a8ba07a9abad345b05c4bf804";
const tshareRewardPoolAddress = "0x60a92645fe34ce7c16f72986e0f980297152535a";
const masonryAddress = "0xe8EA0828FF7BF03c868a2370b83Bc06F50d4eEd9";
const treasuryAddress = "0xE21Fa89dF84902CD88de322A0f5c7024A1b85B68";

const ftmLPs = [
"0x8DFcA21813df0f0d04157779D489bD30843c6D73", // 2dogeFtmLpAddress
"0xB254973e067AF44eB4D506e7117A33C4F3F77783", //2sdogeFtmLpAddress
];

async function calcPool2(masterchef, lps, block, chain) {
let balances = {};
const lpBalances = (
await sdk.api.abi.multiCall({
calls: lps.map((p) => ({
target: p,
params: masterchef,
})),
abi: "erc20:balanceOf",
block,
chain,
})
).output;
let lpPositions = [];
lpBalances.forEach((p) => {
lpPositions.push({
balance: p.output,
token: p.input.target,
});
});
await unwrapUniswapLPs(
balances,
lpPositions,
block,
chain,
(addr) => `${chain}:${addr}`
);
return balances;
}

async function ftmPool2(timestamp, block, chainBlocks) {
return await calcPool2(tshareRewardPoolAddress, ftmLPs, chainBlocks.fantom, "fantom");
}

async function treasury(timestamp, block, chainBlocks) {
let balance = (await sdk.api.erc20.balanceOf({
target: tombTokenAddress,
owner: treasuryAddress,
block: chainBlocks.fantom,
chain: 'fantom'
})).output;

return { [`fantom:${tombTokenAddress}`] : balance }
}
module.exports = {
methodology: "Pool2 deposits consist of 2DOGE/FTM and 2SDOGE/FTM LP tokens deposits while the staking TVL consists of the 2SDOGES tokens locked within the Masonry contract(0xe8EA0828FF7BF03c868a2370b83Bc06F50d4eEd9).",
fantom: {
tvl: async () => ({}),
pool2: ftmPool2,
pool2: pool2(tshareRewardPoolAddress, ftmLPs),
staking: stakingPricedLP(masonryAddress, tshareTokenAddress, "fantom", "0xB254973e067AF44eB4D506e7117A33C4F3F77783", "fantom"),
treasury
},
hallmarks: [
[1646179200, "Rug Pull"]
Expand Down
4 changes: 0 additions & 4 deletions projects/2omb-finance/abi.json

This file was deleted.

Loading

0 comments on commit 18960a3

Please sign in to comment.