forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'DefiLlama:main' into main
- Loading branch information
Showing
1,639 changed files
with
25,779 additions
and
21,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,6 @@ jobs: | |
done | ||
- name: Run ESLint | ||
uses: eslint/github-action@v0 | ||
run: | | ||
npm ci | ||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,6 @@ module.exports = { | |
}, | ||
hallmarks: [ | ||
[1646179200, "Rug Pull"] | ||
] | ||
], | ||
deadFrom: 1646179200 | ||
}; |
Oops, something went wrong.