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
tlatkdgus1 authored Nov 25, 2024
2 parents ad718bb + d796a97 commit 735dcf5
Show file tree
Hide file tree
Showing 1,639 changed files with 25,779 additions and 21,283 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ jobs:
done
- name: Run ESLint
uses: eslint/github-action@v0
run: |
npm ci
npm run lint
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Also, don't hesitate to send a message on [our discord](https://discord.defillam
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 be computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
3. TVL must be computed from blockchain data (reason: https://github.com/DefiLlama/DefiLlama-Adapters/discussions/432), 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 All @@ -25,8 +25,10 @@ This is a work in progress. The goal is to eventually handle historical data. De
If you have any suggestions, want to contribute or want to chat, please join [our discord](https://discord.defillama.com/) and drop a message.

## Testing adapters
```
```bash
node test.js projects/pangolin/index.js
# Add a timestamp at the end to run the adapter at a historical timestamp
node test.js projects/aave/v3.js 1729080692
```

## Changing RPC providers
Expand Down
1,968 changes: 1,065 additions & 903 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"entities": "cd utils;npm i; cd ..; node utils/testInteractive entities",
"useTokenLabels": "node utils/scripts/useTokenLabels.js",
"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",
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
},
"author": "",
"license": "ISC",
"dependencies": {
"@coral-xyz/anchor": "^0.30.1",
"@defillama/sdk": "latest",
"@project-serum/anchor": "^0.26.0",
"@solana/web3.js": "^1.87.6",
Expand Down
10 changes: 0 additions & 10 deletions projects/0xDAO/erc20.json

This file was deleted.

243 changes: 51 additions & 192 deletions projects/0xDAO/index.js
Original file line number Diff line number Diff line change
@@ -1,209 +1,68 @@
const oxLensAbi = require("./oxLens.json");
const solidlyLensAbi = require("./solidlyLens.json");
const veAbi = require("./ve.json");
const oxLensAbi = {
"oxPoolsAddresses": "address[]:oxPoolsAddresses",
"oxPoolsData": "function oxPoolsData(address[] _oxPoolsAddresses) view returns (tuple(address id, address stakingAddress, uint256 stakedTotalSupply, uint256 totalSupply, tuple(address id, string symbol, bool stable, address token0Address, address token1Address, address gaugeAddress, address bribeAddress, address[] bribeTokensAddresses, address fees, uint256 totalSupply) poolData)[])"
}

const veAbi = {
"locked": "function locked(uint256) view returns (int128 amount, uint256 end)"
}

const partnerRewardsPoolAddress = "0xDA006E87DB89e1C5213D4bfBa771e53c91D920aC";
const oxdV1RewardsPoolAddress = "0xDA000779663501df3C9Bc308E7cEc70cE6F04211";
const oxSolidRewardPoolAddress = "0xDA0067ec0925eBD6D583553139587522310Bec60";
const vlOxdAddress = "0xDA00527EDAabCe6F97D89aDb10395f719E5559b9";
const oxdAddress = "0xc5A9848b9d145965d821AaeC8fA32aaEE026492d";
const solidAddress = "0x888EF71766ca594DED1F0FA3AE64eD2941740A20";
const veAddress = "0xcBd8fEa77c2452255f59743f55A3Ea9d83b3c72b";
const oxSolidAddress = "0xDA0053F0bEfCbcaC208A3f867BB243716734D809";
const sanitize = require("./sanitizeWeb3Response.js");

const { standardPoolInfoAbi, addFundsInMasterChef } = require('../helper/masterchef')
const sdk = require('@defillama/sdk')

const shareValue = "uint256:getShareValue"
const xSCREAM = "0xe3D17C7e840ec140a7A51ACA351a482231760824"
const xCREDIT = "0xd9e28749e80D867d5d14217416BFf0e668C10645"
const shareTarot = "function shareValuedAsUnderlying(uint256 _share) returns (uint256 underlyingAmount_)"
const xTAROT = "0x74D1D2A851e339B8cB953716445Be7E8aBdf92F4"

const fBEET = "0xfcef8a994209d6916EB2C86cDD2AFD60Aa6F54b1"

async function tvl(_, __, chainBlocks) {
// 0xDAO Master Chef
const balances = {}
const chain = 'fantom'
const block = chainBlocks[chain]
const calldata = {
chain, block
const { standardPoolInfoAbi } = require('../helper/masterchef')
const { sumTokens2 } = require("../helper/unwrapLPs.js");

async function tvl(api) {
const masterchef = "0xa7821c3e9fc1bf961e280510c471031120716c3d"
const oxd = "0xc165d941481e68696f43ee6e99bfb2b23e0e3114"
const tokens = (await api.fetchList({ lengthAbi: 'poolLength', itemAbi: standardPoolInfoAbi, target: masterchef })).map(i => i.lpToken)
await api.sumTokens({ owner: masterchef, tokens, blacklistedTokens: [oxd] })

// 0xDAO Core
const oxLensAddress = "0xDA00137c79B30bfE06d04733349d98Cf06320e69";

// Fetch pools addresses
const oxPoolsAddresses = await api.call({ target: oxLensAddress, abi: oxLensAbi.oxPoolsAddresses })
const pageSize = 200;
let currentPage = 0;

let addresses = []
while (addresses) {
const start = currentPage * pageSize;
const end = start + pageSize;
addresses = oxPoolsAddresses.slice(start, end);
if (addresses.length === 0) {
break;
}
const transform = addr => `fantom:${addr}`
await addFundsInMasterChef(balances, "0xa7821c3e9fc1bf961e280510c471031120716c3d", block, chain,
transform, standardPoolInfoAbi, [], true, true, "0xc165d941481e68696f43ee6e99bfb2b23e0e3114")

const screamShare = await sdk.api.abi.call({
...calldata,
target: xSCREAM,
abi: shareValue
})
sdk.util.sumSingleBalance(balances, transform("0xe0654C8e6fd4D733349ac7E09f6f23DA256bF475"),
screamShare.output *balances[transform(xSCREAM)] /1e18)
delete balances[transform(xSCREAM)]

const creditShare = await sdk.api.abi.call({
...calldata,
target: xCREDIT,
abi: shareValue
})
sdk.util.sumSingleBalance(balances, transform("0x77128dfdd0ac859b33f44050c6fa272f34872b5e"),
creditShare.output * balances[transform(xCREDIT)] / 1e18)
delete balances[transform(xCREDIT)]

const tarotShare = await sdk.api.abi.call({
...calldata,
target: xTAROT,
abi: shareTarot,
params: sdk.util.convertToBigInt(balances[transform(xTAROT)])
})
sdk.util.sumSingleBalance(balances, transform("0xc5e2b037d30a390e62180970b3aa4e91868764cd"),
tarotShare.output)
delete balances[transform(xTAROT)]
currentPage += 1;

sdk.util.sumSingleBalance(balances, transform("0xf24bcf4d1e507740041c9cfd2dddb29585adce1e"),
balances[transform(fBEET)])
delete balances[transform(fBEET)]
const poolsData = await api.call({ params: [addresses], target: oxLensAddress, abi: oxLensAbi.oxPoolsData })
poolsData.forEach(pool => api.add(pool.poolData.id, pool.totalSupply))
}

// 0xDAO Core
const oxLensAddress = "0xDA00137c79B30bfE06d04733349d98Cf06320e69";
const solidlyLensAddress = "0xDA0024F99A9889E8F48930614c27Ba41DD447c45";
// const oxd = new web3.eth.Contract(erc20Abi, oxdAddress);
// Add locked SOLID
const { amount: lockedSolidAmount } = await api.call({ target: veAddress, params: 2, abi: veAbi.locked })
api.add(solidAddress, lockedSolidAmount);

// Fetch pools addresses
const { output: oxPoolsAddresses } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: oxLensAddress,
abi: oxLensAbi.oxPoolsAddresses
})
const pageSize = 200;
const poolsMap = {};
let currentPage = 0;
// Add staking pools TVL
const oxdV1RewardsPoolBalance = await api.call({ target: oxdV1RewardsPoolAddress, abi: 'erc20:totalSupply' })
const oxSolidRewardsPoolBalance = await api.call({ target: oxSolidRewardPoolAddress, abi: 'erc20:totalSupply' })
const partnerRewardsPoolBalance = await api.call({ target: partnerRewardsPoolAddress, abi: 'erc20:totalSupply' })

// Add pools
const addPools = (pools, reservesData) => {
pools.forEach((pool) => {
const solidlyPoolAddress = pool.poolData.id;
const reserveData = reservesData.find(
(data) => data.id === solidlyPoolAddress
);
const newPool = pool;
newPool.poolData = {
...pool.poolData,
...reserveData,
};
const shareOfTotalSupply = newPool.totalSupply / newPool.poolData.totalSupply
newPool.shareOfTotalSupply = shareOfTotalSupply;
let token0Reserve = newPool.poolData.token0Reserve * shareOfTotalSupply
let token1Reserve = newPool.poolData.token1Reserve * shareOfTotalSupply
if (isNaN(token0Reserve)) {
token0Reserve = "0"
}
if (isNaN(token1Reserve)) {
token1Reserve = "0"
}
newPool.token0Reserve = token0Reserve;
newPool.token1Reserve = token1Reserve;
poolsMap[pool.id] = newPool;
});
};
let addresses = []
while (addresses) {
const start = currentPage * pageSize;
const end = start + pageSize;
addresses = oxPoolsAddresses.slice(start, end);
if (addresses.length === 0) {
break;
}
currentPage += 1;
api.add(oxSolidAddress, oxdV1RewardsPoolBalance);
api.add(oxSolidAddress, partnerRewardsPoolBalance);
api.add(oxSolidAddress, oxSolidRewardsPoolBalance);

const { output: poolsData } = await sdk.api.abi.call({
block,
chain: 'fantom',
params: [addresses],
target: oxLensAddress,
abi: oxLensAbi.oxPoolsData
})
const solidlyPoolsAddresses = poolsData.map((pool) => pool.poolData.id);
const { output: reservesData } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: solidlyLensAddress,
params: [solidlyPoolsAddresses],
abi: solidlyLensAbi.poolsReservesInfo
})
addPools(
sanitize(poolsData),
sanitize(reservesData)
);
}
const pools = Object.values(poolsMap);

// Add TVL from pools to balances
const addBalance = (tokenAddress, amount) => {
const fantomTokenAddress = `fantom:${tokenAddress}`
sdk.util.sumSingleBalance(balances, fantomTokenAddress, amount)
}
pools.forEach(pool => {
const token0 = pool.poolData.token0Address;
const token1 = pool.poolData.token1Address;
const amount0 = pool.token0Reserve;
const amount1 = pool.token1Reserve;
addBalance(token0, amount0);
addBalance(token1, amount1);
});

// Add locked SOLID
const { output: { amount: lockedSolidAmount } } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: veAddress,
params: 2,
abi: veAbi.locked
})
addBalance(solidAddress, lockedSolidAmount);

// Add staking pools TVL
const { output: oxdV1RewardsPoolBalance } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: oxdV1RewardsPoolAddress,
abi: 'erc20:totalSupply'
})
const { output: oxSolidRewardsPoolBalance } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: oxSolidRewardPoolAddress,
abi: 'erc20:totalSupply'
})
const { output: partnerRewardsPoolBalance } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: partnerRewardsPoolAddress,
abi: 'erc20:totalSupply'
})

addBalance(oxSolidAddress, oxdV1RewardsPoolBalance);
addBalance(oxSolidAddress, partnerRewardsPoolBalance);
addBalance(oxSolidAddress, oxSolidRewardsPoolBalance);

// Add vote locked OXD
const { output: voteLockedOxdBalance } = await sdk.api.abi.call({
block,
chain: 'fantom',
target: oxdAddress,
params: vlOxdAddress,
abi: 'erc20:balanceOf'
})
addBalance(oxdAddress, voteLockedOxdBalance);

return balances
return sumTokens2({ api, resolveLP: true, })
}

module.exports = {
fantom: {
tvl
}
fantom: {
tvl
}
}
4 changes: 0 additions & 4 deletions projects/0xDAO/oxLens.json

This file was deleted.

45 changes: 0 additions & 45 deletions projects/0xDAO/sanitizeWeb3Response.js

This file was deleted.

3 changes: 0 additions & 3 deletions projects/0xDAO/solidlyLens.json

This file was deleted.

3 changes: 0 additions & 3 deletions projects/0xDAO/ve.json

This file was deleted.

7 changes: 3 additions & 4 deletions projects/21-co/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { cexExports } = require('../helper/cex')
const bitcoinAddressBook = require('../helper/bitcoin-book/index.js')


const config = {
bitcoin: {
owners: [
'1HTGi4tfXSEtcXD4pk6S3vBs3s64hWY1pW',
'12WZhMFFLHQ4rCMSkeBfbJXRk7aGWyBh1M',
],
owners: bitcoinAddressBook.twentyOneCo
},
solana: {
owners: [
Expand Down
3 changes: 2 additions & 1 deletion projects/2doge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ module.exports = {
},
hallmarks: [
[1646179200, "Rug Pull"]
]
],
deadFrom: 1646179200
};
Loading

0 comments on commit 735dcf5

Please sign in to comment.