-
Notifications
You must be signed in to change notification settings - Fork 22
[WONT MERGE]: Exclude deprecated markets from PoolLens #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 5 commits
84ef62b
94597a8
3ba76ad
b8bd185
14d14cc
22dd253
9e94943
6e55cdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,36 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | |
|
|
||
| const { isTimeBased, blocksPerYear } = getBlockOrTimestampBasedDeploymentInfo(hre.getNetworkName()); | ||
|
|
||
| await deploy("PoolLens", { | ||
| const corePoolComptroller = await deployments.get("Comptroller_Core"); | ||
| const constructorArgs = [isTimeBased, blocksPerYear, corePoolComptroller.address]; | ||
|
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, explore the deploy directory structure and find related files
fd . deploy/ --type f --name "*.ts" | head -20Repository: VenusProtocol/isolated-pools Length of output: 322 🏁 Script executed: # Read the specific file mentioned in the review
wc -l deploy/007-deploy-pool-lens.tsRepository: VenusProtocol/isolated-pools Length of output: 105 🏁 Script executed: # Read the full context of deploy/007-deploy-pool-lens.ts
cat -n deploy/007-deploy-pool-lens.tsRepository: VenusProtocol/isolated-pools Length of output: 1857 🏁 Script executed: # Search for how Comptroller_Core is used in other deploy scripts
rg "Comptroller_Core" deploy/ -A 3 -B 3Repository: VenusProtocol/isolated-pools Length of output: 598 🏁 Script executed: # Check hardhat.config.ts to see network definitions and which are marked as live
cat -n hardhat.config.ts | head -100Repository: VenusProtocol/isolated-pools Length of output: 5299 🏁 Script executed: # Look for skipIfAlreadyDeployed pattern in other deploy scripts
rg "skipIfAlreadyDeployed" deploy/ -B 5 -A 2Repository: VenusProtocol/isolated-pools Length of output: 13685 🏁 Script executed: # Look for where Comptroller_Core is deployed
rg "Comptroller_Core" . --type ts -B 5 -A 5Repository: VenusProtocol/isolated-pools Length of output: 9286 🏁 Script executed: # Check deploy/008 which deploys comptrollers
cat -n deploy/008-deploy-comptrollers.tsRepository: VenusProtocol/isolated-pools Length of output: 2554 🏁 Script executed: # Search for getOrNull pattern in the codebase
rg "getOrNull|deployments\.get" deploy/ -A 2 -B 2Repository: VenusProtocol/isolated-pools Length of output: 5685 🏁 Script executed: # Check the deploymentConfig to see what pools are configured
rg "Core" helpers/deploymentConfig -A 3 -B 3Repository: VenusProtocol/isolated-pools Length of output: 136 🏁 Script executed: # Look for where pools are defined and if "Core" is a pool id
fd deploymentConfig.tsRepository: VenusProtocol/isolated-pools Length of output: 99 🏁 Script executed: # Check if there are references to which pools should be deployed
cat -n helpers/deploymentConfig.ts | head -150Repository: VenusProtocol/isolated-pools Length of output: 7298 🏁 Script executed: # Search for all pool definitions to understand pool naming
rg "pool.id|poolId" helpers/deploymentConfig.ts -B 2 -A 2Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Check what getUnregisteredPools does - it determines which comptrollers get deployed
rg "getUnregisteredPools" helpers/ -A 10Repository: VenusProtocol/isolated-pools Length of output: 987 🏁 Script executed: # Check deployment configurations for BSC networks to see if "Core" pool is defined
rg -A 500 "bscmainnet:" helpers/deploymentConfig.ts | head -150Repository: VenusProtocol/isolated-pools Length of output: 4733 🏁 Script executed: # Check bsctestnet config
rg -A 500 "bsctestnet:" helpers/deploymentConfig.ts | head -150Repository: VenusProtocol/isolated-pools Length of output: 4680 🏁 Script executed: # Look for where poolConfig gets the "Core" pool definition
rg "\"Core\"" helpers/deploymentConfig.tsRepository: VenusProtocol/isolated-pools Length of output: 659 🏁 Script executed: # Check all deployment configuration files
fd deploymentConfig -t fRepository: VenusProtocol/isolated-pools Length of output: 99 🏁 Script executed: # Look for where pool configs are actually defined with the Core pool
rg "id.*Core|Core.*poolConfig" . --type ts | head -20Repository: VenusProtocol/isolated-pools Length of output: 934 🏁 Script executed: # Check the full deploymentConfig to understand when Core pool is configured
wc -l helpers/deploymentConfig.tsRepository: VenusProtocol/isolated-pools Length of output: 104 🏁 Script executed: # Check the section with actual pool config definitions to see if Core is always configured
sed -n '150,500p' helpers/deploymentConfig.tsRepository: VenusProtocol/isolated-pools Length of output: 13887 🏁 Script executed: # Look at deploy scripts to understand execution order - hardhat-deploy executes in numeric order
ls -la deploy/ | grep "^-" | head -30Repository: VenusProtocol/isolated-pools Length of output: 1866 🏁 Script executed: # Check if deploy/007 depends on deploy/008's output
rg "dependsOn|tags.*il|func.tags" deploy/007-deploy-pool-lens.tsRepository: VenusProtocol/isolated-pools Length of output: 103 🏁 Script executed: # Check deploy/008 tags
rg "dependsOn|tags.*il|func.tags" deploy/008-deploy-comptrollers.tsRepository: VenusProtocol/isolated-pools Length of output: 107 🏁 Script executed: # Check if Comptroller_Core might be from external deployments in venus-protocol
rg "Comptroller_Core" node_modules/@venusprotocol/venus-protocol/deployments/ 2>/dev/null | head -20Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Verify hardhat-deploy execution order - does it execute by numeric filename?
# Check if there are any explicit dependencies between 007 and 008
rg "dependsOn" deploy/007-deploy-pool-lens.ts deploy/008-deploy-comptrollers.tsRepository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Look at how deploy/004-swap-router handles getting Comptroller_DeFi which is deployed in 008
cat -n deploy/004-swap-router.ts | head -50Repository: VenusProtocol/isolated-pools Length of output: 2406 🏁 Script executed: # Check if Comptroller_DeFi actually exists or if it's also from external deployments
rg "Comptroller_DeFi" helpers/deploymentConfig.ts -B 3 -A 3Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Search for how hardhat-deploy handles the execution when getting deployments that don't exist yet
# Check if there's any code that ensures deploy/008 runs before 007
rg "run\|tags\|il" deploy/ --type ts -B 2 -A 2 | grep -A 5 -B 5 "tags.*il"Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Look for any hardhat.config overrides for deployment order
rg "deploymentDependencies|namedAccounts|deploy.*order" hardhat.config.tsRepository: VenusProtocol/isolated-pools Length of output: 90 🏁 Script executed: # Check what happens when running deploy scripts - does deploy 008 need to run first?
# Look for any documentation or test that shows execution order
fd README -o DEPLOYMENT_ORDER -o deployment.mdRepository: VenusProtocol/isolated-pools Length of output: 223 🏁 Script executed: # Verify which pool names map to which comptroller deployments in deploy/008
grep -n "pool.id\|pool.name\|Comptroller_" deploy/008-deploy-comptrollers.tsRepository: VenusProtocol/isolated-pools Length of output: 119 🏁 Script executed: # Check if there's a specific way the scripts are meant to be run
cat -n package.json | grep -A 5 -B 5 "deploy"Repository: VenusProtocol/isolated-pools Length of output: 2196 🏁 Script executed: # Check if Comptroller_Core is provided by external venus-protocol deployments or only deployed locally
rg "Comptroller_Core" node_modules/@venusprotocol/ 2>/dev/null | head -5Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Look at the actual pool configurations to confirm Core pool is in every network's config
grep -A 50 "export const globalConfig" helpers/deploymentConfig.ts | grep -A 20 "bscmainnet:"Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Check if there's a deployment execution order documented or if tags affect order
cat -n deploy/006-deploy-pool-registry.ts | tail -10Repository: VenusProtocol/isolated-pools Length of output: 284 🏁 Script executed: # Key insight: Check if deploy scripts that have "il" tag all need to run in sequence
# See if any deployment script references both "il" tag and a previous numbered script's deployment
rg "func.tags.*il" deploy/ -B 2 -A 5Repository: VenusProtocol/isolated-pools Length of output: 4164 🏁 Script executed: # Check actual behavior - are there any snapshots or artifacts showing deployment order?
fd "deployments" --type d | head -5Repository: VenusProtocol/isolated-pools Length of output: 84 🏁 Script executed: # Final confirmation: Check if hardhat-deploy truly executes numerically
# Look at the actual behavior documentation in hardhat-deploy to confirm execution order
cat -n node_modules/hardhat-deploy/package.json | grep -A 2 -B 2 "version"Repository: VenusProtocol/isolated-pools Length of output: 281 Use
Possible fix- const corePoolComptroller = await deployments.get("Comptroller_Core");
- const constructorArgs = [isTimeBased, blocksPerYear, corePoolComptroller.address];
+ const corePoolComptroller = await deployments.getOrNull("Comptroller_Core");
+ if (!corePoolComptroller) {
+ throw new Error("Comptroller_Core deployment not found. Run deploy/008-deploy-comptrollers.ts first.");
+ }
+ const constructorArgs = [isTimeBased, blocksPerYear, corePoolComptroller.address];🤖 Prompt for AI Agents |
||
|
|
||
| const poolLens = await deploy("PoolLens", { | ||
| from: deployer, | ||
| args: [isTimeBased, blocksPerYear], | ||
| args: constructorArgs, | ||
| log: true, | ||
| autoMine: true, | ||
| skipIfAlreadyDeployed: true, | ||
|
Comment on lines
+16
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, check the deploy script file
cat -n deploy/007-deploy-pool-lens.tsRepository: VenusProtocol/isolated-pools Length of output: 1857 🏁 Script executed: # Check if there are constructor args changes in this PR
git diff HEAD~1 deploy/007-deploy-pool-lens.ts 2>/dev/null || echo "Git diff not available, will check file directly"Repository: VenusProtocol/isolated-pools Length of output: 120 🏁 Script executed: # Search for any references to "core-pool exemption" in the codebase
rg "core-pool" --type ts --type js -iRepository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Check what PoolLens contract does and if constructor args relate to exemptions
rg "PoolLens" --type ts --type js -A 3 -B 3 | head -100Repository: VenusProtocol/isolated-pools Length of output: 6575 🏁 Script executed: # Search for the PoolLens contract definition to understand the constructor
fd "PoolLens.sol" -type fRepository: VenusProtocol/isolated-pools Length of output: 242 🏁 Script executed: # Search for "exemption" in the codebase to find what this refers to
rg "exemption" -i --type ts --type js --type sol -B 2 -A 2Repository: VenusProtocol/isolated-pools Length of output: 99 🏁 Script executed: # Check other deploy scripts for comparison with PoolLens deployment pattern
rg "skipIfAlreadyDeployed" deploy/ --type ts -B 5 -A 5 | head -80Repository: VenusProtocol/isolated-pools Length of output: 5215 🏁 Script executed: # Look for recent changes or PR context in version control
git log --oneline deploy/007-deploy-pool-lens.ts 2>/dev/null | head -5Repository: VenusProtocol/isolated-pools Length of output: 139 🏁 Script executed: # Find the PoolLens contract definition
find . -name "PoolLens.sol" -o -name "PoolLens.ts" | grep -v node_modules | grep -v testRepository: VenusProtocol/isolated-pools Length of output: 101 🏁 Script executed: # Search for corePoolComptroller to understand its usage
rg "corePoolComptroller" -B 3 -A 3Repository: VenusProtocol/isolated-pools Length of output: 50387 🏁 Script executed: # Check what the comment says in the git commit
git show 3ba76ad --stat 2>/dev/null | head -20Repository: VenusProtocol/isolated-pools Length of output: 1065 🏁 Script executed: # Look at the PoolLens contract to understand the constructor and what the core comptroller parameter does
rg "contract PoolLens" -A 30 --type-listRepository: VenusProtocol/isolated-pools Length of output: 461 🏁 Script executed: # Read the PoolLens.sol contract to understand the constructor and parameter
cat contracts/Lens/PoolLens.sol | head -150Repository: VenusProtocol/isolated-pools Length of output: 5183 🏁 Script executed: # Search specifically for corePoolComptroller or coreComptroller usage in PoolLens
rg "corePoolComptroller\|coreComptroller" contracts/Lens/PoolLens.sol -A 5 -B 2Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Look for the constructor in PoolLens
ast-grep --pattern 'contract PoolLens { $$$
constructor($_) { $$$
}
}'Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Search for any previous versions or references to PoolLens constructor without corePoolComptroller
rg "PoolLens\(" tests/ -B 2 -A 2 | head -40Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Check if there are any comments or git history about when corePoolComptroller was added
git log --all --oneline --grep="PoolLens" 2>/dev/null | head -10Repository: VenusProtocol/isolated-pools Length of output: 659 🏁 Script executed: # Search for the actual usage of corePoolComptroller in PoolLens to understand the behavior
rg "corePoolComptroller" contracts/Lens/PoolLens.sol -A 10 | head -60Repository: VenusProtocol/isolated-pools Length of output: 1540 🏁 Script executed: # Check if PoolLens was previously deployed and what the constructor looked like before this commit
git show 3ba76ad^:contracts/Lens/PoolLens.sol 2>/dev/null | grep -A 15 "constructor" | head -20Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Check deployments directory to see if PoolLens is already deployed on existing networks
ls -la deployments/ | grep -E "^d" | head -20Repository: VenusProtocol/isolated-pools Length of output: 1227 🏁 Script executed: # Check if PoolLens was deployed in prior deployment scripts
fd "deploy.*pool.*lens" deploy/ -iRepository: VenusProtocol/isolated-pools Length of output: 102 🏁 Script executed: # Verify if there's an existing deployment artifact for PoolLens
find deployments -name "PoolLens.json" 2>/dev/null | head -5Repository: VenusProtocol/isolated-pools Length of output: 264 🏁 Script executed: # Check what the previous version of PoolLens constructor looked like
git show 3ba76ad~1:contracts/Lens/PoolLens.sol 2>/dev/null | grep -A 20 "constructor" | head -25Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Check one of the existing deployment artifacts to see if it has the new constructor args
cat deployments/bscmainnet/PoolLens.json | jq '.args // .constructorArgs' 2>/dev/nullRepository: VenusProtocol/isolated-pools Length of output: 95 🏁 Script executed: # Get a clearer picture of what changed - check the diff for the PoolLens contract
git diff 3ba76ad~1 3ba76ad -- contracts/Lens/PoolLens.sol 2>/dev/null | head -80Repository: VenusProtocol/isolated-pools Length of output: 54 🏁 Script executed: # Let's check the full git commit to see what all changed
git show 3ba76ad --stat 2>/dev/null | head -30Repository: VenusProtocol/isolated-pools Length of output: 1685 🏁 Script executed: # Check if there's a deployment helper or if PoolLens gets deployed elsewhere or upgraded
rg "PoolLens" deploy/ --type ts -lRepository: VenusProtocol/isolated-pools Length of output: 102 🏁 Script executed: # Verify that skipIfAlreadyDeployed really does skip when contract exists
rg "skipIfAlreadyDeployed" -B 5 -A 5 --type ts | grep -A 10 "deploy\(" | head -40Repository: VenusProtocol/isolated-pools Length of output: 95 🏁 Script executed: # Check if there's an upgrade mechanism for PoolLens
rg "upgrade\|Upgrade" deploy/007-deploy-pool-lens.ts -iRepository: VenusProtocol/isolated-pools Length of output: 54 Constructor signature change blocks deployment on networks with existing PoolLens. The PR adds Either remove 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| if (poolLens.newlyDeployed) { | ||
| console.log("Verifying PoolLens..."); | ||
| try { | ||
| await hre.run("verify:verify", { | ||
| address: poolLens.address, | ||
| constructorArguments: constructorArgs, | ||
| }); | ||
| console.log("PoolLens verified successfully"); | ||
| } catch (error: any) { | ||
| if (error.message.includes("Already Verified")) { | ||
| console.log("PoolLens already verified"); | ||
| } else { | ||
| console.error("Verification failed:", error.message); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| func.tags = ["PoolLens", "il"]; | ||
| func.skip = async (hre: HardhatRuntimeEnvironment) => !hre.network.live; | ||
|
|
||
| export default func; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| import chai from "chai"; | ||
| import { ethers } from "hardhat"; | ||
|
|
||
| import { | ||
| Comptroller, | ||
| Comptroller__factory, | ||
| PoolLens, | ||
| PoolLens__factory, | ||
| PoolRegistry__factory, | ||
| } from "../../../typechain"; | ||
| import { getContractAddresses, setForkBlock } from "./utils"; | ||
|
|
||
| const { expect } = chai; | ||
|
|
||
| const FORK = process.env.FORK === "true"; | ||
| const FORKED_NETWORK = process.env.FORKED_NETWORK || "bscmainnet"; | ||
|
|
||
| const { POOL_REGISTRY, COMPTROLLER, CORE_COMPTROLLER, ACC1, BLOCK_NUMBER } = getContractAddresses( | ||
| FORKED_NETWORK as string, | ||
| ); | ||
|
|
||
| // BSC uses block-based, Arbitrum/Optimism/Base/zkSync use time-based | ||
| const TIME_BASED_NETWORKS = [ | ||
| "arbitrumone", | ||
| "arbitrumsepolia", | ||
| "zksyncmainnet", | ||
| "zksyncsepolia", | ||
| "opmainnet", | ||
| "opsepolia", | ||
| "basemainnet", | ||
| "basesepolia", | ||
| "unichainmainnet", | ||
| "unichainsepolia", | ||
| ]; | ||
|
|
||
| const isTimeBased = TIME_BASED_NETWORKS.includes(FORKED_NETWORK); | ||
| const BSC_BLOCKS_PER_YEAR = 70_080_000; | ||
| const ETH_BLOCKS_PER_YEAR = 2_628_000; | ||
| const OPBNB_BLOCKS_PER_YEAR = 126_144_000; | ||
|
|
||
| function getBlocksPerYear(network: string): number { | ||
| if (TIME_BASED_NETWORKS.includes(network)) return 0; | ||
| if (network.includes("opbnb")) return OPBNB_BLOCKS_PER_YEAR; | ||
| if (network === "ethereum" || network === "sepolia") return ETH_BLOCKS_PER_YEAR; | ||
| return BSC_BLOCKS_PER_YEAR; | ||
| } | ||
|
|
||
| if (FORK) { | ||
| describe(`PoolLens Fork Test (${FORKED_NETWORK})`, function () { | ||
| this.timeout(120_000); // fork tests need more time due to RPC calls | ||
| let poolLens: PoolLens; | ||
| let comptroller: Comptroller; | ||
|
|
||
| before(async () => { | ||
| await setForkBlock(BLOCK_NUMBER); | ||
|
|
||
| const poolLensFactory = (await ethers.getContractFactory("PoolLens")) as PoolLens__factory; | ||
| poolLens = await poolLensFactory.deploy( | ||
| isTimeBased, | ||
| getBlocksPerYear(FORKED_NETWORK), | ||
| CORE_COMPTROLLER || ethers.constants.AddressZero, | ||
| ); | ||
| await poolLens.deployed(); | ||
|
|
||
| comptroller = Comptroller__factory.connect(CORE_COMPTROLLER, ethers.provider); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comptroller connection will fail for networks with zero-address CORE_COMPTROLLER. For Proposed fix- comptroller = Comptroller__factory.connect(CORE_COMPTROLLER, ethers.provider);
+ if (CORE_COMPTROLLER && CORE_COMPTROLLER !== ethers.constants.AddressZero) {
+ comptroller = Comptroller__factory.connect(CORE_COMPTROLLER, ethers.provider);
+ }Then guard tests that use 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| describe("getAllPools", () => { | ||
| it("should not revert", async () => { | ||
| const pools = await poolLens.getAllPools(POOL_REGISTRY); | ||
| expect(pools.length).to.be.greaterThan(0); | ||
|
|
||
| for (const pool of pools) { | ||
| expect(pool.comptroller).to.not.equal(ethers.constants.AddressZero); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("getPoolByComptroller", () => { | ||
| it("should not revert and return all markets for core pool", async () => { | ||
| const pool = await poolLens.getPoolByComptroller(POOL_REGISTRY, CORE_COMPTROLLER); | ||
| expect(pool.comptroller).to.equal(CORE_COMPTROLLER); | ||
| expect(pool.vTokens.length).to.be.greaterThan(0); | ||
| for (const vToken of pool.vTokens) { | ||
| expect(vToken.isListed).to.equal(true); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("getPendingRewards", () => { | ||
| it("should not revert", async () => { | ||
| const account = ACC1 || ethers.constants.AddressZero; | ||
| const rewards = await poolLens.getPendingRewards(account, CORE_COMPTROLLER); | ||
| expect(rewards).to.be.an("array"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getPoolBadDebt", () => { | ||
| it("should not revert", async () => { | ||
| const badDebtSummary = await poolLens.getPoolBadDebt(CORE_COMPTROLLER); | ||
| expect(badDebtSummary.comptroller).to.equal(CORE_COMPTROLLER); | ||
| expect(badDebtSummary.badDebts).to.be.an("array"); | ||
| for (const badDebt of badDebtSummary.badDebts) { | ||
| expect(badDebt.vTokenAddress).to.not.equal(ethers.constants.AddressZero); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("vTokenMetadataAll", () => { | ||
| it("should not revert for markets in pool", async () => { | ||
| const allMarkets = await comptroller.getAllMarkets(); | ||
|
|
||
| if (allMarkets.length > 0) { | ||
| const metadata = await poolLens.vTokenMetadataAll(allMarkets); | ||
| expect(metadata.length).to.equal(allMarkets.length); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("getPoolDataFromVenusPool", () => { | ||
| it("should not revert", async () => { | ||
| const poolRegistry = PoolRegistry__factory.connect(POOL_REGISTRY, ethers.provider); | ||
| const venusPool = await poolRegistry.getPoolByComptroller(CORE_COMPTROLLER); | ||
| const poolData = await poolLens.getPoolDataFromVenusPool(POOL_REGISTRY, venusPool); | ||
| expect(poolData.comptroller).to.equal(CORE_COMPTROLLER); | ||
| }); | ||
| }); | ||
|
|
||
| describe("non-core pool filters out vTokens with internalCash == 0", () => { | ||
| it("should not include vTokens with zero internalCash for non-core pools", async () => { | ||
| if (COMPTROLLER === CORE_COMPTROLLER) { | ||
| return; | ||
| } | ||
|
|
||
| const pools = await poolLens.getAllPools(POOL_REGISTRY); | ||
| for (const pool of pools) { | ||
| if (pool.comptroller === CORE_COMPTROLLER) continue; | ||
|
|
||
| for (const vToken of pool.vTokens) { | ||
| expect(vToken.totalCash).to.be.gt(0, `vToken ${vToken.vToken} in pool ${pool.comptroller} has zero cash`); | ||
| } | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("core pool includes all markets", () => { | ||
| it("should include all markets for core pool", async () => { | ||
| if (!CORE_COMPTROLLER || CORE_COMPTROLLER === ethers.constants.AddressZero) { | ||
| return; | ||
| } | ||
|
|
||
| const coreComptroller = Comptroller__factory.connect(CORE_COMPTROLLER, ethers.provider); | ||
| const allMarkets = await coreComptroller.getAllMarkets(); | ||
| const pool = await poolLens.getPoolByComptroller(POOL_REGISTRY, CORE_COMPTROLLER); | ||
| const returnedAddresses = pool.vTokens.map(v => v.vToken.toLowerCase()); | ||
|
|
||
| expect(returnedAddresses.length).to.equal(allMarkets.length); | ||
| for (const market of allMarkets) { | ||
| expect(returnedAddresses).to.include(market.toLowerCase()); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep bad-debt accounting on
getAllMarkets().A market can still carry
badDebt()after it is unlisted or fully paused. Filtering with_getMarkets(...)here will understate bothbadDebtsandtotalBadDebtUsdfor isolated pools—the exact markets most likely to have bad debt are the ones being dropped.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents