Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@thenextblock/hardhat-compound
Advanced tools
npm install @thenextblock/hardhat-compound
yarn add @thenextblock/hardhat-compound
The function deployCompoundV2(CTokenDeployArg[], Signer): Promise<CompoundV2>
deploys Comptroller, Interest rate models, SimplePriceOracle, and cTokens. cToken config is passed
in a form of CTokenDeployArg
. Compound contract types are pre-generated by TypeChain.
import { deployCompoundV2 } from '@thenextblock/hardhat-compound';
const cTokenDeployArgs = [
{
cToken: 'cUSDC',
underlying: '0x1234...',
underlyingPrice: '1000000000000000000000000000000',
collateralFactor: '750000000000000000',
},
];
const { cTokens, comptroller, interestRateModels, priceOracle } = await deployCompoundV2(
cTokenDeployArgs,
deployer,
// optional overrides
{
gasLmit: 5_000_000
}
);
Full example is available at https://github.com/thenextblock/hardhat-compound-example .
You can use this plugin in a Hardhat script to deploy.
import { ethers } from "hardhat";
import { formatUnits, parseUnits } from "ethers/lib/utils";
import { assert } from "chai";
import { deployErc20Token, Erc20Token } from "@thenextblock/hardhat-erc20";
import { CTokenDeployArg, deployCompoundV2, Comptroller,} from "@thenextblock/hardhat-compound";
async function main() {
const [deployer] = await ethers.getSigners();
const UNI_PRICE = "25022748000000000000";
const USDC_PRICE = "1000000000000000000000000000000";
// Deploy USDC ERC20
const USDC: Erc20Token = await deployErc20Token(
{
name: "USDC",
symbol: "USDC",
decimals: 6,
}, deployer
);
// Deploy UNI ERC20
const UNI: Erc20Token = await deployErc20Token(
{
name: "UNI",
symbol: "UNI",
decimals: 18,
},deployer
);
const ctokenArgs: CTokenDeployArg[] = [
{
cToken: "cUNI",
underlying: UNI.address,
underlyingPrice: UNI_PRICE,
collateralFactor: "500000000000000000", // 50%
},
{
cToken: "cUSDC",
underlying: USDC.address,
underlyingPrice: USDC_PRICE,
collateralFactor: "500000000000000000", // 50%
},
];
const { comptroller, cTokens, priceOracle, interestRateModels } =
await deployCompoundV2(ctokenArgs, deployer);
await comptroller._setCloseFactor(parseUnits("0.5", 18).toString());
await comptroller._setLiquidationIncentive(parseUnits("1.08", 18));
const { cUNI, cUSDC } = cTokens;
console.log("Comptroller: ", comptroller.address);
console.log("SimplePriceOralce: ", await comptroller.oracle());
console.log("cUNI: ", cUNI.address);
console.log("cUSDC: ", cUSDC.address);
}
...
You can also use the deployCompoundV2 function from your Hardhat tests Full sample code
FAQs
Compound deployment plugin
We found that @thenextblock/hardhat-compound demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.