2021-11-19 14:22:34 +00:00
|
|
|
const { expect } = require("chai");
|
|
|
|
const hre = require("hardhat");
|
|
|
|
const { web3, deployments, waffle, ethers } = hre;
|
|
|
|
const { provider, deployContract } = waffle;
|
|
|
|
|
|
|
|
const FeeAmount = {
|
|
|
|
LOW: 500,
|
|
|
|
MEDIUM: 3000,
|
|
|
|
HIGH: 10000,
|
|
|
|
};
|
|
|
|
|
|
|
|
const TICK_SPACINGS = {
|
|
|
|
500: 10,
|
|
|
|
3000: 60,
|
|
|
|
10000: 200,
|
|
|
|
};
|
|
|
|
|
2021-11-19 15:54:42 +00:00
|
|
|
const USDC_ADDR = "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8";
|
|
|
|
const WETH_ADDR = "0x82af49447d8a07e3bd95bd0d56f35241523fbab1";
|
2021-11-19 14:22:34 +00:00
|
|
|
|
|
|
|
describe("Uniswap-sell-beta", function() {
|
|
|
|
let UniswapSellBeta, uniswapSellBeta;
|
|
|
|
before(async () => {
|
2021-11-19 21:55:52 +00:00
|
|
|
const account = "0xce2cc46682e9c6d5f174af598fb4931a9c0be68e";
|
2021-11-19 18:43:17 +00:00
|
|
|
[owner, add1, add2] = await ethers.getSigners();
|
|
|
|
|
|
|
|
const tokenArtifact = await artifacts.readArtifact(
|
|
|
|
"@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20"
|
|
|
|
);
|
2021-11-19 20:29:08 +00:00
|
|
|
|
|
|
|
await network.provider.send("hardhat_setBalance", [
|
|
|
|
owner.address,
|
|
|
|
ethers.utils.parseEther("10.0").toHexString(),
|
|
|
|
]);
|
|
|
|
|
|
|
|
await network.provider.send("hardhat_setBalance", [
|
|
|
|
account,
|
|
|
|
ethers.utils.parseEther("10.0").toHexString(),
|
|
|
|
]);
|
2021-11-19 18:43:17 +00:00
|
|
|
|
|
|
|
await hre.network.provider.request({
|
|
|
|
method: "hardhat_impersonateAccount",
|
|
|
|
params: [account],
|
|
|
|
});
|
|
|
|
|
|
|
|
const signer = await ethers.getSigner(account);
|
2021-11-19 20:29:08 +00:00
|
|
|
|
|
|
|
const token = new ethers.Contract(
|
2021-11-19 21:55:52 +00:00
|
|
|
USDC_ADDR,
|
2021-11-19 20:29:08 +00:00
|
|
|
tokenArtifact.abi,
|
|
|
|
ethers.provider
|
|
|
|
);
|
|
|
|
|
|
|
|
console.log((await token.balanceOf(account)).toString());
|
|
|
|
|
2021-11-19 18:43:17 +00:00
|
|
|
await token
|
|
|
|
.connect(signer)
|
2021-11-19 21:55:52 +00:00
|
|
|
.transfer(owner.address, ethers.utils.parseUnits("100", 6));
|
2021-11-19 18:43:17 +00:00
|
|
|
|
|
|
|
await hre.network.provider.request({
|
|
|
|
method: "hardhat_stopImpersonatingAccount",
|
|
|
|
params: [account],
|
|
|
|
});
|
|
|
|
|
2021-11-19 14:22:34 +00:00
|
|
|
UniswapSellBeta = await ethers.getContractFactory(
|
|
|
|
"UniswapSellBetaArbitrum"
|
|
|
|
);
|
|
|
|
uniswapSellBeta = await UniswapSellBeta.deploy();
|
|
|
|
await uniswapSellBeta.deployed();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should have contracts deployed.", async function() {
|
2021-11-19 15:54:42 +00:00
|
|
|
expect(uniswapSellBeta.address).to.exist;
|
2021-11-19 14:22:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should Perfrom a swap", async () => {
|
2021-11-19 21:55:52 +00:00
|
|
|
const tokenArtifact = await artifacts.readArtifact(
|
|
|
|
"@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20"
|
|
|
|
);
|
|
|
|
|
|
|
|
const token = new ethers.Contract(
|
|
|
|
USDC_ADDR,
|
|
|
|
tokenArtifact.abi,
|
|
|
|
ethers.provider
|
|
|
|
);
|
|
|
|
|
|
|
|
const signer = await ethers.getSigner(owner.address);
|
|
|
|
|
|
|
|
await token
|
|
|
|
.connect(signer)
|
|
|
|
.transfer(uniswapSellBeta.address, ethers.utils.parseUnits("10.0", 6));
|
|
|
|
|
2021-11-19 14:22:34 +00:00
|
|
|
const tx = await uniswapSellBeta.sell(
|
2021-11-19 15:54:42 +00:00
|
|
|
WETH_ADDR,
|
2021-11-19 18:43:17 +00:00
|
|
|
USDC_ADDR,
|
|
|
|
3000,
|
2021-11-19 21:55:52 +00:00
|
|
|
ethers.utils.parseUnits("10.0", 6),
|
2021-11-19 18:43:17 +00:00
|
|
|
0,
|
2021-11-19 21:55:52 +00:00
|
|
|
false
|
2021-11-19 14:22:34 +00:00
|
|
|
);
|
|
|
|
console.log(tx);
|
|
|
|
});
|
|
|
|
});
|