// Create a contract instance of the Cozy ETH money market
const cozyEth = new Contract(cozyEthAddress, cozyEthAbi, signer);
// To supply ERC-20 tokens as collateral:
// const cozyToken = new Contract(cozyTokenAddress, cozyTokenAbi, signer); // for tokens
// We're now ready to supply the collateral to the market, but there's
// some preparation we need to do beforehand. For example, ETH
// has 18 decimal places, so we need to take that into account.
// `parseUnits` is a method from ethers.js
const parsedSupplyAmount = parseUnits(supplyAmount, 18); // scale amount based on number of decimals
// If using a token, here is where you'd approve the Cozy Money Market
// contract to spend your tokens. If you trust the Cozy contract,
// approve it to spend the maximum possible amount to avoid future
// approvals and save gas. Below we show a sample snippet of an
// approval transaction and verifying it was successful:
// const approveTx = await token.approve(cozyToken.address, MaxUint256);
// await approveTx.wait();
// const allowance = await token.allowance(signer.address, cozyToken.address);
// if (!allowance.eq(MaxUint256)) {
// logFailure('CozyToken does not have sufficient allowance to spend our token. Exiting script');
// logSuccess('Approval transaction successful. Ready to mint CozyToken with our token');
// Ready to mint our CozyETH from ETH
const mintTx = await cozyEth.mint({ value: parsedSupplyAmount, gasLimit: '5000000' });
// const mintTx =await cozyToken.mint(parsedSupplyAmount); // for tokens
const { log: mintLog, receipt: mintReceipt } = await findLog(mintTx, cozyEth, 'Mint', provider);
logSuccess(`CozyETH successfully minted in transaction ${mintReceipt.transactionHash}`);