Skip to content
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

[VEN-1831]: Multichain fork tests #299

Merged
merged 37 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
228c151
tests: added functionality for multichain forking
Debugger022 Aug 24, 2023
7801b07
tests: added multichain functionality for borrow, rewards and reduce …
Debugger022 Aug 28, 2023
94ecdeb
tests: added multichain functionality for forking
Debugger022 Aug 30, 2023
dc60a00
refactor: moved contract addresses from json to constant ts file
Debugger022 Sep 1, 2023
51b66c9
fix: tests
Debugger022 Sep 2, 2023
d9a280b
merge branch 'develop' into VEN-1831
Debugger022 Sep 25, 2023
dbc5584
fix: resolved conflicts
Debugger022 Oct 30, 2023
3e943c3
fix: tests
Debugger022 Oct 30, 2023
e95be20
tests: added multichain tests for shortfall
Debugger022 Nov 1, 2023
e9f3a63
wip
Debugger022 Nov 1, 2023
6bdb3d5
merge branch 'develop' into VEN-1831
Debugger022 Nov 1, 2023
4f884d6
tests: added multichain for riskFund and shortfall
Debugger022 Nov 2, 2023
932081e
Merge branch 'develop' into VEN-1831
Debugger022 Nov 29, 2023
167b53c
refactor: updated addresses for sepolia to follow same implementation…
Debugger022 Dec 1, 2023
f1143ca
Merge branch 'develop' into VEN-1831
Debugger022 Dec 4, 2023
fd00e09
feat: updating deployment files
Debugger022 Dec 4, 2023
73f9c72
Merge branch 'develop' into VEN-1831
Debugger022 Jan 9, 2024
f6b23d2
feat: updating deployment files
Debugger022 Jan 9, 2024
e816ff2
Merge branch 'develop' into VEN-1831
Debugger022 Jan 10, 2024
1fade86
refactor: import address explicitly
GitGuru7 Jan 10, 2024
d109e32
refactor: function name to lowerCase
Debugger022 Jan 10, 2024
cfdcf00
feat: add ethereum addresses
Debugger022 Jan 29, 2024
9062437
Merge branch 'develop' into VEN-1831
Debugger022 Jan 29, 2024
e3aca15
refactor: pick addresses from npm packages instead of hardcoding
Debugger022 Jan 30, 2024
c0e32f7
refactor: use seplia addresses from npm package and minor refactoring
Debugger022 Jan 30, 2024
c66ea8d
Merge pull request #360 from VenusProtocol/VEN-2353
Debugger022 Jan 31, 2024
25dfd27
Merge branch 'develop' of github.com:VenusProtocol/isolated-pools int…
Debugger022 Mar 4, 2024
967dbbf
chore: add addresses for opBNB testnet and mainnet
Debugger022 Mar 6, 2024
1edf320
Merge branch 'develop' into VEN-1831
Debugger022 Apr 29, 2024
12d8536
chore: import deployments for oracle for arbitrumsepolia
Debugger022 May 2, 2024
e07270c
refactor: remove riskfund tests
Debugger022 May 2, 2024
b022b57
chore: add arbitrumsepolia addresses
Debugger022 May 2, 2024
a47277f
fix: nativeTokenGateway, liquidation and reduceReserves fork tests
Debugger022 May 2, 2024
5beeda7
fix: fork tests for all chains
Debugger022 May 4, 2024
1173de8
Merge branch 'develop' into VEN-1831
Debugger022 Jun 21, 2024
f9144a9
refactor: add imports for arbitrum one
Debugger022 Jun 21, 2024
230e80e
fix: fork tests for all networks
Debugger022 Jun 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions contracts/test/Mocks/MockPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ import { ProtocolShareReserve } from "@venusprotocol/protocol-reserve/contracts/
import { VToken } from "../../VToken.sol";

contract MockPriceOracle is ResilientOracleInterface {
struct TokenConfig {
/// @notice asset address
address asset;
/// @notice `oracles` stores the oracles based on their role in the following order:
/// [main, pivot, fallback],
/// It can be indexed with the corresponding enum OracleRole value
address[3] oracles;
/// @notice `enableFlagsForOracles` stores the enabled state
/// for each oracle in the same order as `oracles`
bool[3] enableFlagsForOracles;
}

mapping(address => uint256) public assetPrices;

//set price in 6 decimal precision
Expand All @@ -28,6 +40,10 @@ contract MockPriceOracle is ResilientOracleInterface {
return assetPrices[asset];
}

function getTokenConfig(address asset) external view returns (TokenConfig memory) {}

function setTokenConfig(TokenConfig memory tokenConfig) public {}

//https://compound.finance/docs/prices
function getUnderlyingPrice(address vToken) public view override returns (uint256) {
return assetPrices[VToken(vToken).underlying()];
Expand Down
17 changes: 14 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ extendConfig((config: HardhatConfig) => {
"node_modules/@venusprotocol/protocol-reserve/deployments/ethereum",
],
bscmainnet: [
"node_modules/@venusprotocol/protocol-reserve/deployments/bscmainnet",
"node_modules/@venusprotocol/oracle/deployments/bscmainnet",
"node_modules/@venusprotocol/venus-protocol/deployments/bscmainnet",
"node_modules/@venusprotocol/protocol-reserve/deployments/bscmainnet",
],
opbnbmainnet: [
"node_modules/@venusprotocol/oracle/deployments/opbnbmainnet",
"node_modules/@venusprotocol/protocol-reserve/deployments/opbnbmainnet",
],
opbnbtestnet: [
"node_modules/@venusprotocol/oracle/deployments/opbnbtestnet",
"node_modules/@venusprotocol/protocol-reserve/deployments/opbnbtestnet",
],
arbitrumsepolia: [
"node_modules/@venusprotocol/oracle/deployments/arbitrumsepolia",
"node_modules/@venusprotocol/protocol-reserve/deployments/arbitrumsepolia",
],
opbnbmainnet: ["node_modules/@venusprotocol/oracle/deployments/opbnbmainnet"],
arbitrumsepolia: ["node_modules/@venusprotocol/protocol-reserve/deployments/arbitrumsepolia"],
arbitrumone: ["node_modules/@venusprotocol/protocol-reserve/deployments/arbitrumone"],
},
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"@venusprotocol/governance-contracts": "2.1.0",
"@venusprotocol/oracle": "2.0.0",
"@venusprotocol/oracle": "2.3.0",
"@venusprotocol/protocol-reserve": "2.2.0",
"@venusprotocol/venus-protocol": "9.0.0",
"bignumber.js": "9.0.0",
Expand Down
19 changes: 3 additions & 16 deletions tests/hardhat/Fork/NativeTokenGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import { Comptroller, ERC20, NativeTokenGateway, VToken } from "../../../typecha
import { initMainnetUser, setForkBlock } from "./utils";

const ADMIN = "0x285960C5B22fD66A736C7136967A3eB15e93CC67";
const COMPTROLLER_BEACON = "0xAE2C3F21896c02510aA187BdA0791cDA77083708";
const VTOKEN_BEACON = "0xfc08aADC7a1A93857f6296C3fb78aBA1d286533a";
const COMPTROLLER_ADDRESS = "0x687a01ecF6d3907658f7A7c714749fAC32336D1B";
const POOL_REGISTRY = "0x61CAff113CCaf05FFc6540302c37adcf077C5179";
const VWETH = "0x7c8ff7d2A1372433726f879BD945fFb250B94c65";
const USDT = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
const VUSDT = "0x8C3e3821259B82fFb32B2450A95d2dcbf161C24E";

const USER1 = "0xf89d7b9c864f589bbF53a82105107622B35EaA40";
const USER2 = "0x974CaA59e49682CdA0AD2bbe82983419A2ECC400";
const BLOCK_NUMBER = 19139865;
const BLOCK_NUMBER = 19781700;

async function configureTimeLock() {
impersonatedTimeLock = await initMainnetUser(ADMIN, ethers.utils.parseUnits("2"));
Expand All @@ -44,16 +41,6 @@ async function setup() {
usdt = await ethers.getContractAt("@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20", USDT);

const comptroller = await ethers.getContractAt("Comptroller", COMPTROLLER_ADDRESS);
const newComptrollerFactory = await ethers.getContractFactory("Comptroller");
const newComptrollerImplementation = await newComptrollerFactory.deploy(POOL_REGISTRY);
const beaconContract = await ethers.getContractAt("UpgradeableBeacon", COMPTROLLER_BEACON);

const newVToken = await ethers.getContractFactory("VToken");
const newVTokenImplementation = await newVToken.deploy();
const vTokenBeaconContract = await ethers.getContractAt("UpgradeableBeacon", VTOKEN_BEACON);

await beaconContract.connect(impersonatedTimeLock).upgradeTo(newComptrollerImplementation.address);
await vTokenBeaconContract.connect(impersonatedTimeLock).upgradeTo(newVTokenImplementation.address);

vusdt = await ethers.getContractAt("VToken", VUSDT);
vweth = await ethers.getContractAt("VToken", VWETH);
Expand Down Expand Up @@ -94,7 +81,7 @@ if (FORK && FORKED_NETWORK === "ethereum") {
const balanceAfterSupplying = await vweth.balanceOf(await user1.getAddress());
await expect(balanceAfterSupplying.sub(balanceBeforeSupplying).toString()).to.closeTo(
parseUnits("10", 8),
parseUnits("1", 5),
parseUnits("1", 7),
);
await expect(tx).to.changeEtherBalances([user1], [supplyAmount.mul(-1)]);
});
Expand All @@ -115,7 +102,7 @@ if (FORK && FORKED_NETWORK === "ethereum") {

await expect(ethBalanceAfter.sub(ethBalanceBefore)).to.closeTo(redeemAmount, parseUnits("1", 16));

expect(await vweth.balanceOf(await user1.getAddress())).to.eq(0);
expect(await vweth.balanceOf(await user1.getAddress())).to.closeTo(0, 10);
});
});

Expand Down
Loading
Loading