
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@morpho-labs/morpho-ethers-contract
Advanced tools
This package aims to facilitate the integration around morpho with ethers-v5. Instead of importing ABIs, finding implementations, and guessing which functions to call, this package gives you typed classes by using typechain, and mainnet addresses of deployed contracts.
The package contains all contracts to interract with Morpho and withe the Compound and Aave pools.
NB: for security reasons, we invite you to always check the addresses of the contracts used, and check whether they are indeed those of Morpho.
You will find more information on the integration of Morpho in the developer documentation.
npm install @morpho-labs/morpho-ethers-contract
yarn add @morpho-labs/morpho-ethers-contract
import { providers, Wallet } from "ethers";
import { formatUnits, parseUnits } from "ethers/lib/utils";
import addresses from "@morpho-labs/morpho-ethers-contract/addresses"
import {
MorphoAaveV2Lens__factory,
MorphoAaveV2__factory,
ERC20__factory,
} from "@morpho-labs/morpho-ethers-contract";
(async () => {
const provider = new providers.StaticJsonRpcProvider(process.env.RPC, "mainnet");
const morphoAaveLens = MorphoAaveV2Lens__factory.connect(addresses.morphoAave.lens, provider);
// now you have autocompletion for morpho contract
const morphoAaveMarkets = await morphoAaveLens.getAllMarkets();
// For example, you can easily supply on Morpho
const signer = new Wallet(process.env.PRIVATE_KEY!, provider);
const morphoAaveV2 = MorphoAaveV2__factory.connect(addresses.morphoAave.morpho, provider);
const toSupply = parseUnits("10"); // 10 DAI
const daiAddress = "0x6b175474e89094c44da98b954eedeac495271d0f";
const aDaiAddress = "0x028171bCA77440897B824Ca71D1c56caC55b68A3";
// We first need to approve the amount to supply through the ERC20 token
const DAI = ERC20__factory.connect(daiAddress, signer);
const approvalTransaction = await DAI.approve(morphoAaveV2.address, toSupply);
console.log(`Approval transaction: https://etherscan.io/tx/${approvalTransaction.hash}`);
await approvalTransaction.wait(); // wait until transaction was mined
console.log(`${formatUnits(toSupply)} DAI approved`);
const supplyTransaction = await morphoAaveV2["supply(address,address,uint256)"](
aDaiAddress, // poolToken aka aToken for aave
signer.address, // onBehalf of the signer
toSupply // amount to supply in WEI units
);
console.log(
`Supply on Morpho-AaveV2 transaction: https://etherscan.io/tx/${supplyTransaction.hash}`
);
const receipt = await supplyTransaction.wait();
console.log(
`You have successfully supplied ${formatUnits(
toSupply
)} DAI on Morpho Aave, with a gas consuption of ${formatUnits(receipt.gasUsed, "gwei")} gWei`
);
})();
FAQs
Use Morpho contracts with ethers js
We found that @morpho-labs/morpho-ethers-contract demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.