2022-09-03 09:33:32 +00:00
|
|
|
import { expect, should } from "chai";
|
|
|
|
import hre, { ethers, waffle } from "hardhat";
|
|
|
|
import type { Signer, Contract } from "ethers";
|
2022-09-03 13:55:11 +00:00
|
|
|
import { ecsign, ecrecover, pubToAddress } from "ethereumjs-util";
|
|
|
|
import { keccak256 } from "@ethersproject/keccak256";
|
|
|
|
import { defaultAbiCoder } from "@ethersproject/abi";
|
2022-09-03 09:33:32 +00:00
|
|
|
import { BigNumber } from "bignumber.js";
|
|
|
|
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
|
|
|
|
import { addresses } from "../../../scripts/tests/mainnet/addresses";
|
|
|
|
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector";
|
|
|
|
import { abis } from "../../../scripts/constant/abis";
|
|
|
|
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
|
2022-09-03 13:55:11 +00:00
|
|
|
import { parseEther, parseUnits } from "ethers/lib/utils";
|
2022-09-03 09:33:32 +00:00
|
|
|
import { encodeSpells } from "../../../scripts/tests/encodeSpells";
|
|
|
|
import encodeFlashcastData from "../../../scripts/tests/encodeFlashcastData";
|
2022-09-03 13:55:11 +00:00
|
|
|
import { ConnectV2CompoundV3__factory, IERC20__factory } from "../../../typechain";
|
2022-09-03 09:33:32 +00:00
|
|
|
import { tokens } from "../../../scripts/tests/mainnet/tokens";
|
|
|
|
const { provider } = waffle;
|
2022-09-04 16:31:38 +00:00
|
|
|
import { getChainId } from "hardhat";
|
2022-09-03 09:33:32 +00:00
|
|
|
|
|
|
|
const ABI = [
|
|
|
|
"function balanceOf(address account) public view returns (uint256)",
|
|
|
|
"function approve(address spender, uint256 amount) external returns(bool)",
|
|
|
|
"function transfer(address recipient, uint256 amount) external returns (bool)"
|
|
|
|
];
|
|
|
|
|
2022-09-03 13:55:11 +00:00
|
|
|
const market = "0xc3d688B66703497DAA19211EEdff47f25384cdc3";
|
|
|
|
const user = "0x0a904e5e342d853952ad8159502dc1a29f9b084e";
|
|
|
|
const wethWhale = "0xf04a5cc80b1e94c69b48f5ee68a08cd2f09a7c3e";
|
|
|
|
const account = "0x72a53cdbbcc1b9efa39c834a540550e23463aacb";
|
|
|
|
const mnemonic = "test test test test test test test test test test test junk";
|
|
|
|
const connectorName = "COMPOUND-V3-X";
|
|
|
|
|
|
|
|
const cometABI = [
|
2022-09-03 09:33:32 +00:00
|
|
|
{
|
|
|
|
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
|
|
name: "balanceOf",
|
|
|
|
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
|
|
stateMutability: "view",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
|
|
name: "borrowBalanceOf",
|
|
|
|
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
|
|
stateMutability: "view",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "asset", type: "address" },
|
|
|
|
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
|
|
],
|
|
|
|
name: "supply",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "dst", type: "address" },
|
|
|
|
{ internalType: "address", name: "asset", type: "address" },
|
|
|
|
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
|
|
],
|
|
|
|
name: "supplyTo",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "dst", type: "address" },
|
|
|
|
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
|
|
],
|
|
|
|
name: "transfer",
|
|
|
|
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "dst", type: "address" },
|
|
|
|
{ internalType: "address", name: "asset", type: "address" },
|
|
|
|
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
|
|
],
|
|
|
|
name: "transferAsset",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "src", type: "address" },
|
|
|
|
{ internalType: "address", name: "dst", type: "address" },
|
|
|
|
{ internalType: "address", name: "asset", type: "address" },
|
|
|
|
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
|
|
],
|
|
|
|
name: "transferAssetFrom",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "", type: "address" },
|
|
|
|
{ internalType: "address", name: "", type: "address" }
|
|
|
|
],
|
|
|
|
name: "userCollateral",
|
|
|
|
outputs: [
|
|
|
|
{ internalType: "uint128", name: "balance", type: "uint128" },
|
|
|
|
{ internalType: "uint128", name: "_reserved", type: "uint128" }
|
|
|
|
],
|
|
|
|
stateMutability: "view",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
|
|
name: "userNonce",
|
|
|
|
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
|
|
stateMutability: "view",
|
|
|
|
type: "function"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "asset", type: "address" },
|
|
|
|
{ internalType: "uint256", name: "amount", type: "uint256" }
|
|
|
|
],
|
|
|
|
name: "withdraw",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
2022-09-03 16:43:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "owner", type: "address" },
|
|
|
|
{ internalType: "address", name: "manager", type: "address" },
|
|
|
|
{ internalType: "bool", name: "isAllowed_", type: "bool" },
|
|
|
|
{ internalType: "uint256", name: "nonce", type: "uint256" },
|
|
|
|
{ internalType: "uint256", name: "expiry", type: "uint256" },
|
|
|
|
{ internalType: "uint8", name: "v", type: "uint8" },
|
|
|
|
{ internalType: "bytes32", name: "r", type: "bytes32" },
|
|
|
|
{ internalType: "bytes32", name: "s", type: "bytes32" }
|
|
|
|
],
|
|
|
|
name: "allowBySig",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
|
|
|
},
|
2022-09-03 18:03:45 +00:00
|
|
|
{
|
|
|
|
inputs: [],
|
|
|
|
name: "version",
|
|
|
|
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
|
|
stateMutability: "view",
|
|
|
|
type: "function"
|
2022-09-04 04:43:54 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
inputs: [
|
|
|
|
{ internalType: "address", name: "manager", type: "address" },
|
|
|
|
{ internalType: "bool", name: "isAllowed_", type: "bool" }
|
|
|
|
],
|
|
|
|
name: "allow",
|
|
|
|
outputs: [],
|
|
|
|
stateMutability: "nonpayable",
|
|
|
|
type: "function"
|
2022-09-03 18:03:45 +00:00
|
|
|
}
|
2022-09-03 09:33:32 +00:00
|
|
|
];
|
2022-09-03 13:55:11 +00:00
|
|
|
|
|
|
|
const comet = new ethers.Contract(market, cometABI);
|
|
|
|
const wethContract = new ethers.Contract(tokens.weth.address, ABI);
|
|
|
|
|
|
|
|
describe("Import Compound v3 Position", function () {
|
2022-09-03 09:33:32 +00:00
|
|
|
let dsaWallet0: any;
|
|
|
|
let masterSigner: Signer;
|
2022-09-03 13:55:11 +00:00
|
|
|
let signer: any;
|
|
|
|
let wallet0: any;
|
|
|
|
let walletSigner: any;
|
2022-09-03 09:33:32 +00:00
|
|
|
let instaConnectorsV2: Contract;
|
|
|
|
let connector: any;
|
|
|
|
|
|
|
|
const wallets = provider.getWallets();
|
2022-09-03 13:55:11 +00:00
|
|
|
const [wallet1, wallet2, wallet3] = wallets;
|
|
|
|
|
2022-09-03 09:33:32 +00:00
|
|
|
const wallet = ethers.Wallet.fromMnemonic(mnemonic);
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
await hre.network.provider.request({
|
|
|
|
method: "hardhat_reset",
|
|
|
|
params: [
|
|
|
|
{
|
|
|
|
forking: {
|
2022-09-03 13:55:11 +00:00
|
|
|
//@ts-ignore
|
2022-09-03 09:33:32 +00:00
|
|
|
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
|
2022-09-04 07:36:52 +00:00
|
|
|
blockNumber: 15469858
|
2022-09-03 09:33:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
masterSigner = await getMasterSigner();
|
|
|
|
|
2022-09-03 13:55:11 +00:00
|
|
|
await hre.network.provider.send("hardhat_setBalance", [account, ethers.utils.parseEther("10").toHexString()]);
|
|
|
|
await hre.network.provider.send("hardhat_setBalance", [wethWhale, ethers.utils.parseEther("10").toHexString()]);
|
2022-09-03 09:33:32 +00:00
|
|
|
|
|
|
|
await hre.network.provider.request({
|
|
|
|
method: "hardhat_impersonateAccount",
|
|
|
|
params: [wethWhale]
|
|
|
|
});
|
2022-09-03 13:55:11 +00:00
|
|
|
signer = await ethers.getSigner(wethWhale);
|
|
|
|
[wallet0] = await ethers.getSigners();
|
2022-09-03 09:33:32 +00:00
|
|
|
|
|
|
|
await hre.network.provider.request({
|
|
|
|
method: "hardhat_impersonateAccount",
|
|
|
|
params: [wallet.address]
|
|
|
|
});
|
|
|
|
walletSigner = await ethers.getSigner(wallet.address);
|
2022-09-03 13:55:11 +00:00
|
|
|
instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2);
|
|
|
|
connector = await deployAndEnableConnector({
|
|
|
|
connectorName,
|
|
|
|
contractArtifact: ConnectV2CompoundV3__factory,
|
|
|
|
signer: masterSigner,
|
|
|
|
connectors: instaConnectorsV2
|
|
|
|
});
|
2022-09-03 09:33:32 +00:00
|
|
|
});
|
|
|
|
|
2022-09-03 13:55:11 +00:00
|
|
|
describe("check user Compound position", async () => {
|
2022-09-04 12:10:00 +00:00
|
|
|
it("Should create Compound v3 position of WETH(collateral) and USDC(debt)", async () => {
|
2022-09-03 13:55:11 +00:00
|
|
|
await wethContract.connect(signer).transfer(wallet.address, parseEther("100"));
|
|
|
|
// approve WETH to market
|
|
|
|
|
|
|
|
await wethContract.connect(walletSigner).approve(market, parseEther("100"));
|
|
|
|
|
|
|
|
//deposit WETH in Compound
|
|
|
|
await comet.connect(walletSigner).supply(tokens.weth.address, parseEther("100"));
|
|
|
|
console.log("Supplied WETH on compound");
|
|
|
|
|
|
|
|
//borrow Base from compound
|
|
|
|
await comet.connect(walletSigner).withdraw(tokens.usdc.address, parseUnits("100", 6));
|
|
|
|
console.log("Borrowed USDC from compound");
|
2022-09-03 09:33:32 +00:00
|
|
|
});
|
|
|
|
|
2022-09-03 13:55:11 +00:00
|
|
|
it("Should check position of user", async () => {
|
|
|
|
expect((await comet.connect(signer).userCollateral(wallet.address, tokens.weth.address)).balance).to.be.gte(
|
|
|
|
new BigNumber(100).multipliedBy(1e18).toString()
|
2022-09-03 09:33:32 +00:00
|
|
|
);
|
2022-09-03 13:55:11 +00:00
|
|
|
|
|
|
|
expect(await comet.connect(signer).borrowBalanceOf(wallet.address)).to.be.gte(
|
|
|
|
new BigNumber(100).multipliedBy(1e6).toString()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Deployment", async () => {
|
|
|
|
it("Should set correct name", async () => {
|
|
|
|
expect(await connector.name()).to.eq("CompoundV3-v1.0");
|
2022-09-03 09:33:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("DSA wallet setup", async () => {
|
|
|
|
it("Should build DSA v2", async () => {
|
2022-09-03 13:55:11 +00:00
|
|
|
dsaWallet0 = await buildDSAv2(wallet.address);
|
2022-09-03 09:33:32 +00:00
|
|
|
expect(!!dsaWallet0.address).to.be.true;
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Deposit ETH into DSA wallet", async function () {
|
|
|
|
await wallet0.sendTransaction({
|
|
|
|
to: dsaWallet0.address,
|
|
|
|
value: ethers.utils.parseEther("10")
|
|
|
|
});
|
2022-09-03 13:55:11 +00:00
|
|
|
|
2022-09-03 09:33:32 +00:00
|
|
|
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10"));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-09-04 12:10:00 +00:00
|
|
|
describe("Compound position migration - Using `toggleManagerUsingPermit` spell by Manager DSA", async () => {
|
2022-09-04 16:21:18 +00:00
|
|
|
let initialbal: any;
|
|
|
|
let initialborrow: any;
|
2022-09-04 12:10:00 +00:00
|
|
|
|
2022-09-03 09:33:32 +00:00
|
|
|
it("Should migrate Compound position", async () => {
|
2022-09-04 16:21:18 +00:00
|
|
|
initialbal = new BigNumber(
|
|
|
|
(await comet.connect(wallet0).userCollateral(dsaWallet0.address, tokens.weth.address)).balance
|
|
|
|
);
|
|
|
|
initialborrow = new BigNumber(await comet.connect(wallet0).borrowBalanceOf(dsaWallet0.address));
|
|
|
|
|
2022-09-03 09:33:32 +00:00
|
|
|
const DOMAIN_TYPEHASH = keccak256(
|
2022-09-03 13:55:11 +00:00
|
|
|
ethers.utils.toUtf8Bytes("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
|
2022-09-03 09:33:32 +00:00
|
|
|
);
|
|
|
|
const PERMIT_TYPEHASH = keccak256(
|
2022-09-03 13:55:11 +00:00
|
|
|
ethers.utils.toUtf8Bytes(
|
|
|
|
"Authorization(address owner,address manager,bool isAllowed,uint256 nonce,uint256 expiry)"
|
|
|
|
)
|
2022-09-03 09:33:32 +00:00
|
|
|
);
|
2022-09-03 13:55:11 +00:00
|
|
|
const name = keccak256(ethers.utils.toUtf8Bytes("Compound USDC"));
|
|
|
|
const version = keccak256(ethers.utils.toUtf8Bytes("0"));
|
2022-09-04 16:21:18 +00:00
|
|
|
//hardhat network chainID
|
2022-09-04 16:31:38 +00:00
|
|
|
const chainId = new BigNumber(await getChainId()).toFixed(0);
|
2022-09-03 09:33:32 +00:00
|
|
|
const DOMAIN_SEPARATOR = keccak256(
|
|
|
|
defaultAbiCoder.encode(
|
|
|
|
["bytes32", "bytes32", "bytes32", "uint256", "address"],
|
2022-09-03 13:55:11 +00:00
|
|
|
[DOMAIN_TYPEHASH, name, version, chainId, market]
|
2022-09-03 09:33:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2022-09-04 01:08:39 +00:00
|
|
|
let nonce = new BigNumber(await comet.connect(walletSigner).userNonce(wallet.address)).toFixed(0);
|
2022-09-03 09:33:32 +00:00
|
|
|
//Approving max amount
|
|
|
|
const amount = ethers.constants.MaxUint256;
|
2022-09-04 07:36:52 +00:00
|
|
|
const expiry = Date.now() + 100 * 60;
|
2022-09-04 01:08:39 +00:00
|
|
|
const structHash = keccak256(
|
|
|
|
defaultAbiCoder.encode(
|
|
|
|
["bytes32", "address", "address", "bool", "uint256", "uint256"],
|
|
|
|
[PERMIT_TYPEHASH, wallet.address, dsaWallet0.address, true, nonce, expiry]
|
|
|
|
)
|
|
|
|
);
|
2022-09-03 09:33:32 +00:00
|
|
|
const digest = keccak256(
|
|
|
|
ethers.utils.solidityPack(
|
|
|
|
["bytes1", "bytes1", "bytes32", "bytes32"],
|
2022-09-04 01:08:39 +00:00
|
|
|
["0x19", "0x01", DOMAIN_SEPARATOR, structHash]
|
2022-09-03 09:33:32 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
const { v, r, s } = ecsign(Buffer.from(digest.slice(2), "hex"), Buffer.from(wallet.privateKey.slice(2), "hex"));
|
2022-09-03 15:26:38 +00:00
|
|
|
let buffer = ethers.utils.parseUnits("100", 3).toNumber();
|
2022-09-03 13:55:11 +00:00
|
|
|
let amount0 = new BigNumber(await comet.connect(wallet0).borrowBalanceOf(wallet.address)).plus(buffer);
|
2022-09-03 09:33:32 +00:00
|
|
|
let amountB = new BigNumber(amount0.toString()).multipliedBy(5).dividedBy(1e4);
|
|
|
|
let amountWithFee = amount0.plus(amountB);
|
2022-09-04 16:31:38 +00:00
|
|
|
|
|
|
|
console.log(`\n\tOwner: ${wallet.address}`);
|
|
|
|
console.log(`\tManager: ${dsaWallet0.address}`);
|
|
|
|
console.log(`\tdomain speparator: ${DOMAIN_SEPARATOR}`);
|
|
|
|
console.log(`\tdomain typehash: ${DOMAIN_TYPEHASH}`);
|
|
|
|
console.log(`\tpermit typehash: ${PERMIT_TYPEHASH}`);
|
|
|
|
console.log(`\tnonce: ${nonce}`);
|
|
|
|
console.log(`\texpiry: ${expiry}`);
|
|
|
|
console.log(`\tv: ${v}`);
|
|
|
|
console.log(`\tr: ${ethers.utils.hexlify(r)}`);
|
|
|
|
console.log(`\ts: ${ethers.utils.hexlify(s)}`);
|
|
|
|
console.log(`\tDigest: ${digest}`);
|
|
|
|
console.log(`\tstructHash: ${structHash}`);
|
|
|
|
console.log(`\tblock timestamp: ${(await provider.getBlock(15469858)).timestamp}`);
|
2022-09-04 01:08:39 +00:00
|
|
|
|
2022-09-04 07:36:52 +00:00
|
|
|
console.log(await ethers.provider.getBalance(walletSigner.address));
|
2022-09-04 12:10:00 +00:00
|
|
|
const spells1 = [
|
|
|
|
{
|
|
|
|
connector: "COMPOUND-V3-X",
|
|
|
|
method: "toggleAccountManagerWithPermit",
|
|
|
|
args: [
|
|
|
|
market,
|
|
|
|
wallet.address,
|
|
|
|
dsaWallet0.address,
|
|
|
|
true,
|
|
|
|
nonce,
|
|
|
|
expiry,
|
|
|
|
v,
|
|
|
|
ethers.utils.hexlify(r),
|
|
|
|
ethers.utils.hexlify(s)
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
let [targets, calldata] = encodeSpells(spells1);
|
|
|
|
console.log(targets);
|
|
|
|
console.log(calldata);
|
|
|
|
let tx = await dsaWallet0.connect(walletSigner).cast(...encodeSpells(spells1), wallet0.address);
|
|
|
|
const receipt = await tx.wait();
|
2022-09-03 09:33:32 +00:00
|
|
|
console.log("DSA Permitted as manager");
|
|
|
|
|
|
|
|
const flashSpells = [
|
|
|
|
{
|
|
|
|
connector: "COMPOUND-V3-X",
|
|
|
|
method: "paybackOnBehalf",
|
2022-09-03 13:55:11 +00:00
|
|
|
args: [market, tokens.usdc.address, wallet.address, ethers.constants.MaxUint256, 0, 0]
|
2022-09-03 09:33:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
connector: "COMPOUND-V3-X",
|
2022-09-04 04:43:54 +00:00
|
|
|
method: "transferAssetOnBehalf",
|
|
|
|
args: [market, tokens.weth.address, wallet.address, dsaWallet0.address, ethers.constants.MaxUint256, 0, 0]
|
2022-09-03 09:33:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
connector: "COMPOUND-V3-X",
|
|
|
|
method: "borrow",
|
2022-09-03 13:55:11 +00:00
|
|
|
args: [market, tokens.usdc.address, amountWithFee.toFixed(0), 0, 0]
|
2022-09-03 09:33:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
connector: "INSTAPOOL-C",
|
|
|
|
method: "flashPayback",
|
|
|
|
args: [tokens.usdc.address, amountWithFee.toFixed(0), 0, 0]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
const spells = [
|
|
|
|
{
|
|
|
|
connector: "INSTAPOOL-C",
|
|
|
|
method: "flashBorrowAndCast",
|
|
|
|
args: [tokens.usdc.address, amount0.toFixed(), 5, encodeFlashcastData(flashSpells), "0x"]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-09-04 12:10:00 +00:00
|
|
|
tx = await dsaWallet0.connect(walletSigner).cast(...encodeSpells(spells), wallet0.address);
|
2022-09-03 09:33:32 +00:00
|
|
|
await tx.wait();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should check DSA COMPOUND position", async () => {
|
2022-09-03 13:55:11 +00:00
|
|
|
expect((await comet.connect(wallet0).userCollateral(dsaWallet0.address, tokens.weth.address)).balance).to.be.gte(
|
2022-09-04 16:21:18 +00:00
|
|
|
initialbal.plus(100 * 1e18).toFixed(0)
|
2022-09-03 13:55:11 +00:00
|
|
|
);
|
|
|
|
expect(await comet.connect(wallet0).borrowBalanceOf(dsaWallet0.address)).to.be.gte(
|
2022-09-04 16:21:18 +00:00
|
|
|
initialborrow.plus(100 * 1e6).toFixed(0)
|
2022-09-03 09:33:32 +00:00
|
|
|
);
|
2022-09-04 07:36:52 +00:00
|
|
|
|
|
|
|
expect((await comet.connect(wallet0).userCollateral(wallet.address, tokens.weth.address)).balance).to.be.lte(
|
|
|
|
ethers.utils.parseEther("0")
|
|
|
|
);
|
|
|
|
expect(await comet.connect(wallet0).borrowBalanceOf(wallet.address)).to.be.lte(ethers.utils.parseUnits("0", 6));
|
2022-09-03 09:33:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|