Skip to content

Commit

Permalink
chore: add addresses for opBNB testnet and mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Debugger022 committed Mar 6, 2024
1 parent 25dfd27 commit 967dbbf
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 33 deletions.
10 changes: 8 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ extendConfig((config: HardhatConfig) => {
"node_modules/@venusprotocol/venus-protocol/deployments/bscmainnet",
"node_modules/@venusprotocol/protocol-reserve/deployments/bscmainnet",
],
opbnbmainnet: ["node_modules/@venusprotocol/oracle/deployments/opbnbmainnet"],
opbnbtestnet: ["node_modules/@venusprotocol/oracle/deployments/opbnbtestnet"],
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",
],
},
};
}
Expand Down
20 changes: 9 additions & 11 deletions tests/hardhat/Fork/borrowAndRepayTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ if (FORK) {

let vTokenPrice = exchangeRateCollateral.mul(TOKEN1Price).div(convertToUnit(1, 18));

let weighhtedPriceTOKEN1 = vTokenPrice
let weightedPriceTOKEN1 = vTokenPrice
.mul(vTOKEN1CollateralFactor.collateralFactorMantissa)
.div(convertToUnit(1, 18));

let expectedMintAmount = mintAmount.mul(convertToUnit(1, 18)).div(exchangeRateCollateral);

// ACC1 pre borrow checks
let expectedLiquidityAcc1 = weighhtedPriceTOKEN1.mul(expectedMintAmount).div(convertToUnit(1, 18));
let expectedLiquidityAcc1 = weightedPriceTOKEN1.mul(expectedMintAmount).div(convertToUnit(1, 18));
let [err, liquidity, shortfall] = await comptroller.getBorrowingPower(ACC1);
expect(expectedMintAmount).equals(await vTOKEN1.balanceOf(ACC1));
expect(err).equals(0);
Expand All @@ -201,16 +201,14 @@ if (FORK) {

vTokenPrice = exchangeRateCollateral.mul(TOKEN1Price).div(convertToUnit(1, 18));

weighhtedPriceTOKEN1 = vTokenPrice
.mul(vTOKEN1CollateralFactor.collateralFactorMantissa)
.div(convertToUnit(1, 18));
weightedPriceTOKEN1 = vTokenPrice.mul(vTOKEN1CollateralFactor.collateralFactorMantissa).div(convertToUnit(1, 18));
expectedMintAmount = mintAmount.mul(convertToUnit(1, 18)).div(await vTOKEN1.exchangeRateStored());

expectedLiquidityAcc1 = weighhtedPriceTOKEN1.mul(await vTOKEN1.balanceOf(ACC1)).div(convertToUnit(1, 18));
expectedLiquidityAcc1 = weightedPriceTOKEN1.mul(await vTOKEN1.balanceOf(ACC1)).div(convertToUnit(1, 18));

[err, liquidity, shortfall] = await comptroller.getBorrowingPower(ACC2);

let expectedLiquidityAcc2 = weighhtedPriceTOKEN1.mul(expectedMintAmount).div(convertToUnit(1, 18));
let expectedLiquidityAcc2 = weightedPriceTOKEN1.mul(expectedMintAmount).div(convertToUnit(1, 18));
[err, liquidity, shortfall] = await comptroller.getBorrowingPower(ACC2);
expect(expectedMintAmount).equals(await vTOKEN1.balanceOf(ACC2));
expect(err).equals(0);
Expand All @@ -234,8 +232,8 @@ if (FORK) {
expect(liquidity).equals(expectedLiquidityAcc1); // ************************************
expect(shortfall).equals(0);

// ********************************Mine 300000 blocks***********************************/
await mine(300000);
// ********************************Mine 30000 blocks***********************************/
await mine(30000);
await vTOKEN2.accrueInterest();
let borrowIndexCurrent = await vTOKEN2.borrowIndex();

Expand Down Expand Up @@ -297,14 +295,14 @@ if (FORK) {
const TOKEN1Price = await priceOracle.getUnderlyingPrice(VTOKEN1);
const TOKEN2Price = await priceOracle.getUnderlyingPrice(VTOKEN2);
const vTokenPrice = exchangeRateCollateral.mul(TOKEN1Price).div(convertToUnit(1, 18));
const weighhtedPriceTOKEN1 = vTokenPrice
const weightedPriceTOKEN1 = vTokenPrice
.mul(vTOKEN1CollateralFactor.collateralFactorMantissa)
.div(convertToUnit(1, 18));

const expectedMintAmount = mintAmount.mul(convertToUnit(1, 18)).div(await vTOKEN1.exchangeRateStored());

// checks
let expectedLiquidityAcc1 = weighhtedPriceTOKEN1.mul(await vTOKEN1.balanceOf(ACC1)).div(convertToUnit(1, 18));
let expectedLiquidityAcc1 = weightedPriceTOKEN1.mul(await vTOKEN1.balanceOf(ACC1)).div(convertToUnit(1, 18));
let [err, liquidity, shortfall] = await comptroller.getBorrowingPower(ACC1);

expect(expectedMintAmount).equals(await vTOKEN1.balanceOf(ACC1));
Expand Down
64 changes: 63 additions & 1 deletion tests/hardhat/Fork/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import GovernanceBscMainnet from "@venusprotocol/governance-contracts/deployments/bscmainnet.json";
import GovernanceBscTestnet from "@venusprotocol/governance-contracts/deployments/bsctestnet.json";
import GovernanceEthMainnet from "@venusprotocol/governance-contracts/deployments/ethereum.json";
import GovernanceOpBnbMainnet from "@venusprotocol/governance-contracts/deployments/opbnbmainnet.json";
import GovernanceOpBnbTestnet from "@venusprotocol/governance-contracts/deployments/opbnbtestnet.json";
import GovernanceSepTestnet from "@venusprotocol/governance-contracts/deployments/sepolia.json";
import OracleBscMainnet from "@venusprotocol/oracle/deployments/bscmainnet.json";
import OracleBscTestnet from "@venusprotocol/oracle/deployments/bsctestnet.json";
import OracleEthMainnet from "@venusprotocol/oracle/deployments/ethereum.json";
import OracleOpBnbMainnet from "@venusprotocol/oracle/deployments/opbnbmainnet.json";
import OracleOpBnbTestnet from "@venusprotocol/oracle/deployments/opbnbtestnet.json";
import OracleSepTestnet from "@venusprotocol/oracle/deployments/sepolia.json";
import PsrBscMainnet from "@venusprotocol/protocol-reserve/deployments/bscmainnet.json";
import PsrBscTestnet from "@venusprotocol/protocol-reserve/deployments/bsctestnet.json";
import PsrOpBnbTestnet from "@venusprotocol/protocol-reserve/deployments/opbnbtestnet/ProtocolShareReserve.json";
import PsrSepTestnet from "@venusprotocol/protocol-reserve/deployments/sepolia.json";
import CoreBscMainnet from "@venusprotocol/venus-protocol/deployments/bscmainnet.json";
import CoreBscTestnet from "@venusprotocol/venus-protocol/deployments/bsctestnet.json";
Expand All @@ -16,9 +21,11 @@ import CoreEthMainnet from "@venusprotocol/venus-protocol/deployments/ethereum.j
import { contracts as MainnetContracts } from "../../../deployments/bscmainnet.json";
import { contracts as TestnetContracts } from "../../../deployments/bsctestnet.json";
import { contracts as EthereumContracts } from "../../../deployments/ethereum.json";
import { contracts as OpBnbMainnetContracts } from "../../../deployments/opbnbmainnet.json";
import { contracts as OpBnbTestnetContracts } from "../../../deployments/opbnbtestnet.json";
import { contracts as SepoliaContracts } from "../../../deployments/sepolia.json";

export const contractAddreseses = {
export const contractAddresses = {
sepolia: {
ADMIN: "0x94fa6078b6b8a26F0B6EDFFBE6501B22A10470fB",
ACM: GovernanceSepTestnet.contracts.AccessControlManager.address,
Expand Down Expand Up @@ -119,4 +126,59 @@ export const contractAddreseses = {
ACC3: "0x394d1d517e8269596a7E4Cd1DdaC1C928B3bD8b3",
BLOCK_NUMBER: 33966470,
},
opbnbtestnet: {
ADMIN: GovernanceOpBnbTestnet?.contracts?.NormalTimelock?.address || "0xb15f6EfEbC276A3b9805df81b5FB3D50C2A62BDf",
ACM: GovernanceOpBnbTestnet.contracts.AccessControlManager.address,
VTOKEN1: OpBnbTestnetContracts.VToken_vBTCB_Core.address,
VTOKEN2: OpBnbTestnetContracts.VToken_vETH_Core.address,
VUSDT: "",
COMPTROLLER: OpBnbTestnetContracts.Comptroller_Core.address,
PSR: PsrOpBnbTestnet.address,
SHORTFALL: "",
RISKFUND: "",
REWARD_DISTRIBUTOR1: "",
POOL_REGISTRY: OpBnbTestnetContracts.PoolRegistry.address,
RESILIENT_ORACLE: OracleOpBnbTestnet.contracts.ResilientOracle.address,
// CHAINLINK_ORACLE: OracleOpBnbTestnet.contracts.ChainlinkOracle.address,
CHAINLINK_ORACLE: "",
BINANCE_ORACLE: OracleOpBnbTestnet.contracts.BinanceOracle.address,
SWAP_ROUTER_CORE_POOL: "",
USDT: "",
TOKEN1: "0x7Af23F9eA698E9b953D2BD70671173AaD0347f19", // BTCB
TOKEN2: "0x94680e003861D43C6c0cf18333972312B6956FF1", // ETH
TOKEN1_HOLDER: "0x2ce1d0ffd7e869d9df33e28552b12ddded326706",
TOKEN2_HOLDER: "0x638eb8dfff094fd1d52c5a198b44984806c521e5",
USDT_HOLDER: "0x8894E0a0c962CB723c1976a4421c95949bE2D4E3",
ACC1: "0x3Ac99C7853b58f4AA38b309D372562a5A88bB9C1",
ACC2: "0xA4a04C2D661bB514bB8B478CaCB61145894563ef",
ACC3: "0x394d1d517e8269596a7E4Cd1DdaC1C928B3bD8b3",
BLOCK_NUMBER: 22749193,
},
opbnbmainnet: {
ADMIN: GovernanceOpBnbMainnet?.contracts?.NormalTimelock?.address || "0xC46796a21a3A9FAB6546aF3434F2eBfFd0604207",
ACM: GovernanceOpBnbMainnet.contracts.AccessControlManager.address,
VTOKEN1: OpBnbMainnetContracts.VToken_vUSDT_Core.address,
VTOKEN2: OpBnbMainnetContracts.VToken_vFDUSD_Core.address,
VUSDT: "",
COMPTROLLER: OpBnbMainnetContracts.Comptroller_Core.address,
PSR: "0xDDc9017F3073aa53a4A8535163b0bf7311F72C52",
SHORTFALL: "",
RISKFUND: "",
REWARD_DISTRIBUTOR1: "",
POOL_REGISTRY: OpBnbMainnetContracts.PoolRegistry.address,
RESILIENT_ORACLE: OracleOpBnbMainnet.contracts.ResilientOracle.address,
CHAINLINK_ORACLE: "",
BINANCE_ORACLE: OracleOpBnbMainnet.contracts.BinanceOracle.address,
SWAP_ROUTER_CORE_POOL: "",
USDT: "0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3",
TOKEN1: "0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3", // USDT
TOKEN2: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", // FDUSD
TOKEN1_HOLDER: "0x001ceb373c83ae75b9f5cf78fc2aba3e185d09e2",
TOKEN2_HOLDER: "0x001ceb373c83ae75b9f5cf78fc2aba3e185d09e2",
USDT_HOLDER: "0x8894E0a0c962CB723c1976a4421c95949bE2D4E3",
ACC1: "0x3Ac99C7853b58f4AA38b309D372562a5A88bB9C1",
ACC2: "0xA4a04C2D661bB514bB8B478CaCB61145894563ef",
ACC3: "0x394d1d517e8269596a7E4Cd1DdaC1C928B3bD8b3",
BLOCK_NUMBER: 17881611,
},
};
4 changes: 2 additions & 2 deletions tests/hardhat/Fork/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { impersonateAccount, setBalance } from "@nomicfoundation/hardhat-network
import { NumberLike } from "@nomicfoundation/hardhat-network-helpers/dist/src/types";
import { ethers, network } from "hardhat";

import { contractAddreseses } from "./constants";
import { contractAddresses } from "./constants";

export function getContractAddresses(name: string) {
return contractAddreseses[name];
return contractAddresses[name];
}

export const forking = (blockNumber: number, fn: () => void) => {
Expand Down
50 changes: 33 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3092,7 +3092,39 @@ __metadata:
languageName: node
linkType: hard

"@venusprotocol/isolated-pools@^2.3.0, @venusprotocol/isolated-pools@workspace:.":
"@venusprotocol/isolated-pools@npm:2.3.0":
version: 2.3.0
resolution: "@venusprotocol/isolated-pools@npm:2.3.0"
dependencies:
"@nomiclabs/hardhat-ethers": ^2.2.3
"@openzeppelin/contracts": ^4.8.3
"@openzeppelin/contracts-upgradeable": ^4.8.3
"@openzeppelin/hardhat-upgrades": ^1.21.0
"@solidity-parser/parser": ^0.13.2
ethers: ^5.7.0
hardhat-deploy: ^0.11.14
module-alias: ^2.2.2
checksum: e3ef4115048b41415e50ff8d7c4297a93e88f7914ce7eb061d1c976d686c8c5c0082d01612a615a61ef9d130ff2a72e7acba2a6612eda0fc44e12ccb9277c411
languageName: node
linkType: hard

"@venusprotocol/isolated-pools@npm:^2.3.0":
version: 2.6.0
resolution: "@venusprotocol/isolated-pools@npm:2.6.0"
dependencies:
"@nomiclabs/hardhat-ethers": ^2.2.3
"@openzeppelin/contracts": ^4.8.3
"@openzeppelin/contracts-upgradeable": ^4.8.3
"@openzeppelin/hardhat-upgrades": ^1.21.0
"@solidity-parser/parser": ^0.13.2
ethers: ^5.7.0
hardhat-deploy: ^0.11.14
module-alias: ^2.2.2
checksum: 324bdaa9d6de3f812800f78429d4f35812fc5d71a9127b6c6726e5f7b20924b074d5ed2935cf0c4977f0db053624ad9ba27e9207184bcd4672dd9ead3986ba12
languageName: node
linkType: hard

"@venusprotocol/isolated-pools@workspace:.":
version: 0.0.0-use.local
resolution: "@venusprotocol/isolated-pools@workspace:."
dependencies:
Expand Down Expand Up @@ -3153,22 +3185,6 @@ __metadata:
languageName: unknown
linkType: soft

"@venusprotocol/isolated-pools@npm:2.3.0":
version: 2.3.0
resolution: "@venusprotocol/isolated-pools@npm:2.3.0"
dependencies:
"@nomiclabs/hardhat-ethers": ^2.2.3
"@openzeppelin/contracts": ^4.8.3
"@openzeppelin/contracts-upgradeable": ^4.8.3
"@openzeppelin/hardhat-upgrades": ^1.21.0
"@solidity-parser/parser": ^0.13.2
ethers: ^5.7.0
hardhat-deploy: ^0.11.14
module-alias: ^2.2.2
checksum: e3ef4115048b41415e50ff8d7c4297a93e88f7914ce7eb061d1c976d686c8c5c0082d01612a615a61ef9d130ff2a72e7acba2a6612eda0fc44e12ccb9277c411
languageName: node
linkType: hard

"@venusprotocol/oracle@npm:1.10.0":
version: 1.10.0
resolution: "@venusprotocol/oracle@npm:1.10.0"
Expand Down

0 comments on commit 967dbbf

Please sign in to comment.