mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 16:53:02 +08:00
Bugfixes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const sdk = require("@defillama/sdk");
|
||||
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
|
||||
const { staking } = require("../helper/staking");
|
||||
const { tombTvl } = require("../helper/tomb");
|
||||
|
||||
const ravTokenAddress = "0x9B7c74Aa737FE278795fAB2Ad62dEFDbBAedFBCA";
|
||||
const rshareTokenAddress = "0xD81E377E9cd5093CE752366758207Fc61317fC70";
|
||||
@@ -13,57 +12,6 @@ const mADALPs = [
|
||||
"0x73bc306Aa2D393ff5aEb49148b7B2C9a8E5d39c8", //rsharemADALpAddress
|
||||
];
|
||||
|
||||
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 madaPool2(timestamp, block, chainBlocks) {
|
||||
return await calcPool2(rshareRewardPoolAddress, mADALPs, chainBlocks['milkomeda'], "milkomeda");
|
||||
}
|
||||
|
||||
async function treasury(timestamp, block, chainBlocks) {
|
||||
let balance = (await sdk.api.erc20.balanceOf({
|
||||
target: ravTokenAddress,
|
||||
owner: treasuryAddress,
|
||||
block: chainBlocks['milkomeda'],
|
||||
chain: 'milkomeda'
|
||||
})).output;
|
||||
|
||||
return { [`milkomeda:${ravTokenAddress}`] : balance }
|
||||
}
|
||||
module.exports = {
|
||||
methodology: "Pool2 deposits consist of RAV/mADA and RSHARE/mADA LP tokens deposits while the staking TVL consists of the RSHARES tokens locked within the Boardroom contract(0x618C166262282DcB6Cdc1bFAB3808e2fa4ADFEc2).",
|
||||
milkomeda: {
|
||||
tvl: async () => ({}),
|
||||
pool2: madaPool2,
|
||||
staking: staking(boardroomAddress, rshareTokenAddress, "milkomeda"),
|
||||
treasury
|
||||
},
|
||||
|
||||
};
|
||||
...tombTvl(ravTokenAddress, rshareTokenAddress, rshareRewardPoolAddress, boardroomAddress, mADALPs, "milkomeda", undefined, false, mADALPs[1])
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ const retry = require('../helper/retry')
|
||||
const axios = require("axios")
|
||||
const BigNumber = require('bignumber.js')
|
||||
|
||||
const pool = {
|
||||
eth: "0xe82906b6B1B04f631D126c974Af57a3A7B6a99d9",
|
||||
const oldPools = {
|
||||
ethereum: ["0xe82906b6B1B04f631D126c974Af57a3A7B6a99d9",],
|
||||
}
|
||||
|
||||
const chainConfig = {
|
||||
ethereum: { chainId: 1, },
|
||||
polygon: { chainId: 137, },
|
||||
moonbeam: { chainId: 1284, },
|
||||
optimism: { chainId: 10, },
|
||||
@@ -17,19 +18,6 @@ const chainConfig = {
|
||||
const weth = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
const moonbeamGLMR = "moonbeam:0x0000000000000000000000000000000000000802"
|
||||
|
||||
async function eth(time, block) {
|
||||
const balances = {
|
||||
[weth]: (await sdk.api.eth.getBalance({ target: pool.eth, block })).output
|
||||
}
|
||||
await sumTokensAndLPsSharedOwners(balances, [
|
||||
"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", //wbtc
|
||||
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", //usdc
|
||||
"0x6b175474e89094c44da98b954eedeac495271d0f", //dai
|
||||
"0xdac17f958d2ee523a2206206994597c13d831ec7", //usdt
|
||||
].map(t => [t, false]), [pool.eth], block)
|
||||
return balances
|
||||
}
|
||||
|
||||
async function getChainData(chain) {
|
||||
const { chainId } = chainConfig[chain]
|
||||
|
||||
@@ -49,17 +37,25 @@ async function getChainData(chain) {
|
||||
|
||||
function chainTVL(chain) {
|
||||
return {
|
||||
tvl: async (time, block, chainBlocks) => {
|
||||
tvl: async (time, _block, chainBlocks) => {
|
||||
const balances = {}
|
||||
const block = chainBlocks[chain]
|
||||
const transform = await getChainTransform(chain)
|
||||
const { poolAddress, assets } = await getChainData(chain)
|
||||
const pools = oldPools[chain] || []
|
||||
const poolAddresses = [poolAddress, ...pools,]
|
||||
|
||||
await sumTokensAndLPsSharedOwners(balances, assets.map(t => [t, false]), [poolAddress], chainBlocks[chain], chain, transform)
|
||||
await sumTokensAndLPsSharedOwners(balances, assets.map(t => [t, false]), poolAddresses, block, chain, transform)
|
||||
|
||||
if (balances[moonbeamGLMR]) {
|
||||
balances['moonbeam'] = BigNumber(balances[moonbeamGLMR]).dividedBy(10 ** 18).toFixed(0)
|
||||
delete balances[moonbeamGLMR]
|
||||
}
|
||||
|
||||
if (chain === 'ethereum')
|
||||
for(const pool of poolAddresses)
|
||||
sdk.util.sumSingleBalance(balances, weth, (await sdk.api.eth.getBalance({ target: pool, block })).output)
|
||||
|
||||
return balances
|
||||
|
||||
}
|
||||
@@ -69,9 +65,6 @@ function chainTVL(chain) {
|
||||
const chainTVLObject = Object.keys(chainConfig).reduce((agg, chain) => ({ ...agg, [chain]: chainTVL(chain) }), {})
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
tvl: eth
|
||||
},
|
||||
...chainTVLObject,
|
||||
methodology: `Counts the tokens in pool address in different chains`
|
||||
}
|
||||
@@ -471,6 +471,7 @@ async function transformArbitrumAddress() {
|
||||
async function transformFuseAddress() {
|
||||
const mapping = {
|
||||
'0x0000000000000000000000000000000000000000': '0x970b9bb2c0444f5e81e9d0efb84c8ccdcdcaf84d', // FUSE
|
||||
'0x0be9e53fd7edac9f859882afdda116645287c629': '0x970b9bb2c0444f5e81e9d0efb84c8ccdcdcaf84d', // FUSE
|
||||
'0x620fd5fa44BE6af63715Ef4E65DDFA0387aD13F5': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
|
||||
'0x94Ba7A27c7A95863d1bdC7645AC2951E0cca06bA': '0x6B175474E89094C44Da98b954EedeAC495271d0F', // DAI
|
||||
'0xFaDbBF8Ce7D5b7041bE672561bbA99f79c532e10': '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT
|
||||
|
||||
Reference in New Issue
Block a user