Skip to content

Commit

Permalink
fix broken adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Apr 16, 2024
1 parent 6f235af commit 2d05843
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 316 deletions.
33 changes: 4 additions & 29 deletions projects/candycity/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const sdk = require("@defillama/sdk");
const BigNumber = require("bignumber.js");
const { toUSDTBalances } = require('../helper/balances')
const { get } = require('../helper/http');
const { staking, stakings } = require("../helper/staking");
const { staking, } = require("../helper/staking");
const { getUniTVL } = require('../helper/unknownTokens')

const chainTvl = getUniTVL({
Expand All @@ -12,8 +8,6 @@ const chainTvl = getUniTVL({

const CANDY_TOKEN = '0x06C04B0AD236e7Ca3B3189b1d049FE80109C7977';

const CMC_API_URL = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/market-pairs/latest?slug=bored-candy-city'

const STAKING_CONTRACTS = [
'0xDAf7c0e2882818b46c36AdBCe95399821Eca08F8', // masterchef
'0x8FEf43b1f3046F8f58A76c64aD01Bc8d82ff0ad1', // candy vault
Expand All @@ -28,32 +22,13 @@ const VESTING_CONTRACTS = [
'0x427f1230A547566a51F5Ffd5698BB65c06acA2D2', // candy vesting
]

async function fetchTvl(timestamp, ethBlock, chainBlocks) {
let cmc_response = await get(CMC_API_URL)
const candyPrice = cmc_response.data.marketPairs[0].price
const balances = await stakings(STAKING_CONTRACTS, CANDY_TOKEN)(timestamp, ethBlock, chainBlocks)
const candyBalances = Object.values(balances)[0]

return toUSDTBalances(BigNumber(candyBalances).times(BigNumber(candyPrice)).div(1e18));
}

async function fetchVesting(timestamp, ethBlock, chainBlocks) {
let cmc_response = await get(CMC_API_URL)
const candyPrice = cmc_response.data.marketPairs[0].price
const balances = await stakings(VESTING_CONTRACTS, CANDY_TOKEN)(timestamp, ethBlock, chainBlocks)
const candyBalances = Object.values(balances)[0]

return toUSDTBalances(BigNumber(candyBalances).times(BigNumber(candyPrice)).div(1e18));
}

module.exports = {
misrepresentedTokens: true,
methodology:
"Factory address (0x84343b84EEd78228CCFB65EAdEe7659F246023bf) is used to find the LP pairs. TVL is equal to the liquidity on the AMM and the candy tokens in the staking pools / vault / vesting contract / lock contract.",
cronos: {
tvl: chainTvl,
staking: fetchTvl,
vesting: fetchVesting

staking: staking(STAKING_CONTRACTS, CANDY_TOKEN),
vesting: staking(VESTING_CONTRACTS, CANDY_TOKEN),
},
}; // node test.js projects/crodex/index.js
}
46 changes: 3 additions & 43 deletions projects/championfinance/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const sdk = require("@defillama/sdk");
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
const { pool2 } = require('../helper/pool2')
const { stakings } = require("../helper/staking");

const avicTokenAddress = "0x59B18817CA9f4ad2dEE6FBf30132dF6AEb9D763d";
const chamTokenAddress = "0xc65bC1E906771e105fBAcBD8dfE3862Ee7BE378E";
const chamRewardPoolAddress = "0x649EfBF7D96B06a2bD0fB134621AC9dD031923A4";
const boardroomAddress = [
Expand All @@ -16,49 +14,11 @@ const lps = [
"0xd6F18CDe9A52A9D815dd3C03C2325D453E32BDef", //CHAMUsdcLpAddress
"0x8392a728aEe00a26E99AF8e837c33591944e033a", // EVIC-WETH.e Address
];
const shareLps = "0xd6F18CDe9A52A9D815dd3C03C2325D453E32BDef";

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 pool2(timestamp, block, chainBlocks) {
return await calcPool2(chamRewardPoolAddress, lps, chainBlocks.avax);
}
async function tvl(timestamp, block, chainBlocks) {
let balances = {};
return balances;
}
module.exports = {
avax: {
tvl: tvl,
pool2: pool2,
tvl: () => ({}),
pool2: pool2(chamRewardPoolAddress, lps),
staking: stakings(boardroomAddress, chamTokenAddress)
}
};
2 changes: 1 addition & 1 deletion projects/hyperliquid-spot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { post } = require('../helper/http')
async function tvl(api) {
let data= await post('https://api.hyperliquid.xyz/info', {"type":"tvlBreakdown"})
data = data.find(i => i.protocol === "Hyperliquid Spot DEX")
data.tokens.forEach(i => api.addCGToken('tether', api.usdcValue))
data.tokens.forEach(i => api.addCGToken('tether', +i.usdcValue))
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions projects/init-capital/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const tvl = async (api) => {

if (chainId === 81457) {
pools = Object.keys(allPoolData[chainId]).map(
(pool) => allPoolData[chainId][pool].rebaseWrapperAddress
(pool) => allPoolData[chainId][pool].rebaseWrapperAddress ?? allPoolData[chainId][pool].poolAddress
);
} else {
pools = Object.keys(allPoolData[chainId]);
Expand All @@ -36,7 +36,7 @@ const borrowed = async (api) => {
if (chainId === 81457) {
debts = await api.multiCall({
calls: debts.map((debt, i) => ({
target: allPoolData[chainId][pools[i]].rebaseWrapperAddress,
target: allPoolData[chainId][pools[i]].rebaseWrapperAddress ?? allPoolData[chainId][pools[i]].poolAddress,
params: [debt],
})),
abi: "function toAmt(uint256) returns (uint256)",
Expand Down
57 changes: 5 additions & 52 deletions projects/kittyfinance/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const sdk = require("@defillama/sdk");
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
const { stakingUnknownPricedLP, staking } = require("../helper/staking");
const { staking } = require("../helper/staking");
const { pool2 } = require("../helper/pool2");

const avaxKitty = "0x788AE3b5D153d49F8DB649aacbA1857f744b739e";
const polyKitty = "0x182dB1252C39073eeC9d743F13b5eeb80FDE314e";
const avaxCat = "0x094BFaC9894d2A2A35771D0BD6d2447689190F32";
const polyCat = "0xB932D203f83B8417Be0F61D9dAFad09cc24a4715";
const polyChef = "0xc17c09f7615c660dd5A7C1051E096240CF75685a";
Expand All @@ -19,59 +16,15 @@ const avaxLPs = [
"0x2d9A57C484C60241f5340a145a3004c7E4cfE040", // CAT-AVAX LP
];

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 polyPool2(timestamp, block, chainBlocks) {
return await calcPool2(polyChef, polyLPs, chainBlocks.polygon);
}

async function avaxPool2(timestamp, block, chainBlocks) {
return await calcPool2(avaxChef, avaxLPs, chainBlocks.avax);
}

module.exports = {
polygon: {
tvl: async () => ({}),
pool2: polyPool2,
staking: stakingUnknownPricedLP(
polyNursery,
polyCat,
"polygon",
polyLPs[1],
(addr) => `polygon:${addr}`
),
pool2: pool2(polyChef, polyLPs),
staking: staking(polyNursery, polyCat),
},
avax: {
tvl: async () => ({}),
pool2: avaxPool2,
pool2: pool2(avaxChef, avaxLPs),
staking: staking(avaxNursery, avaxCat),
},
};
43 changes: 2 additions & 41 deletions projects/nacho-finance/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const sdk = require("@defillama/sdk");
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
const { staking } = require("../helper/staking");
const { pool2 } = require("../helper/pool2");

const tombTokenAddress = "0xcD86152047e800d67BDf00A4c635A8B6C0e5C4c2";
const tshareTokenAddress = "0x948D0a28b600BDBd77AF4ea30E6F338167034181";
const tshareRewardPoolAddress = "0xdD694F459645eb6EfAE934FE075403760eEb9aA1";
const masonryAddress = "0x1ad667aCe03875fe48534c65BFE14191CF81fd64";
Expand All @@ -12,50 +10,13 @@ const ftmLPs = [
"0x2c97767BFa132E3785943cf14F31ED3f025405Ea", // NSHARE-MATIC
"0xcD90217f76F3d8d5490FD0434F597516767DaDe1", // ETH-MATIC
"0x354789e7bBAC6E3d3143A0457324cD80bD0BE050", // ETH-USDC
"0xfc4a30f328E946ef3E727BD294a93e84c2e43c24" // NBOND
];

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) => {
if (p.input.target != '0xfc4a30f328E946ef3E727BD294a93e84c2e43c24') {
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.polygon);
}

module.exports = {
methodology: "Pool2 deposits consist of NACHO/ETH, NSHARE/MATIC LP, ETH/MATIC LP, ETH/USDC LP and NBOND tokens deposits while the staking TVL consists of the NSHARE tokens locked within the Bowl contract.",
polygon: {
tvl: async () => ({}),
pool2: ftmPool2,
pool2: pool2(tshareRewardPoolAddress, ftmLPs),
staking: staking(masonryAddress, tshareTokenAddress),
},
};
59 changes: 6 additions & 53 deletions projects/partialfinance/index.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,21 @@
const sdk = require("@defillama/sdk");
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
const { staking, stakingPricedLP } = require("../helper/staking");
const { staking, } = require("../helper/staking");
const { pool2 } = require('../helper/pool2')

const partialTokenAddress = "0x9486fDA4C1192db69a08CA7235E2E6bAf31B467B";
const pshareTokenAddress = "0x8C64D18E9d4A7b8e8c10C5c5a4b8D6D83cb15002";
const pshareRewardPoolAddress = "0xd5f73D588C3CaCd45B334f873b7B2E7DfaA4cCc7";
const boardroomAddress = "0x5FcE757a1aa5C489B008a4Df6CA2ef9088B5bCA4";
const treasuryAddress = "0x5Cf2EB28083B95A7c0E73FE0F1312e4497FC2A53";

const ftmLPs = [
"0xe78c2b734F0e7BD708B1a6d79a0cF8937C4DA278", // partialFtmLpAddress
"0x802ed580E7b48abBfaBf6edC73009705CE210d0b", // pshareFtmLpAddress
];
]

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(pshareRewardPoolAddress, ftmLPs, chainBlocks.fantom);
}

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

return { [`fantom:${partialTokenAddress}`] : balance }
}
module.exports = {
deadFrom: "2024-04-01",
methodology: "Pool2 deposits consist of PARTIAL/FTM and PSHARE/FTM LP tokens deposits while the staking TVL consists of the PSHARES tokens locked within the Boardroom contract(0x5FcE757a1aa5C489B008a4Df6CA2ef9088B5bCA4).",
fantom: {
tvl: async () => ({}),
pool2: ftmPool2,
staking: stakingPricedLP(boardroomAddress, pshareTokenAddress, "fantom", "0x802ed580E7b48abBfaBf6edC73009705CE210d0b", "fantom"),
treasury
pool2: pool2(pshareRewardPoolAddress, ftmLPs),
staking: staking(boardroomAddress, pshareTokenAddress),
},
};
Loading

0 comments on commit 2d05843

Please sign in to comment.