@@ -13,5 +13,5 @@ npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
-npx hardhat run scripts/deploy.ts
+npx hardhat run scripts/deployCalc.ts
```
@@ -0,0 +1,36 @@
+export default [
+ {
+ "inputs": [
+ "internalType": "address",
+ "name": "tokenA",
+ "type": "address"
+ },
+ "internalType": "uint256",
+ "name": "amountA",
+ "type": "uint256"
+ "name": "tokenB",
+ "internalType": "uint24",
+ "name": "fee",
+ "type": "uint24"
+ }
+ ],
+ "name": "getQuote",
+ "outputs": [
+ "name": "amountB",
+ "stateMutability": "view",
+ "type": "function"
+]
@@ -4,5 +4,6 @@ export default {
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
UNIV3: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
UNIV3_FACTORY: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
- ZERO: '0x0000000000000000000000000000000000000000'
+ ZERO: '0x0000000000000000000000000000000000000000',
+ CALC: '0x72fe77C67a8028cf9A14422062A3F718C4151EF1'
}
@@ -6,7 +6,7 @@ import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol';
import 'hardhat/console.sol';
-contract CalcTest {
+contract Calc {
IUniswapV3Factory factory = IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
function getQuote(address tokenA, uint amountA, address tokenB, uint24 fee) public view returns (uint256 amountB) {
@@ -1,13 +1,12 @@
import { ethers } from "hardhat";
async function main() {
- const CalcTest = await ethers.getContractFactory("CalcTest");
- const calc = await CalcTest.deploy();
+ const Calc = await ethers.getContractFactory("Calc");
+ const calc = await Calc.deploy();
await calc.deployed();
- console.log(`Lock deployed to ${calc.address}`);
- //0xA56768f700434321765a373B040c17BBB25eB803
+ console.log(`Calc deployed to ${calc.address}`);
// We recommend this pattern to be able to use async/await everywhere
@@ -0,0 +1,14 @@
+import {web3} from "hardhat";
+import fee from "../config/fee";
+import contracts from "../config/contracts";
+
+describe('Calc test', () => {
+ it('Univ3 swap test', async () => {
+ const Calc_ABI = require('../abi/Calc_ABI').default
+ let calc = new web3.eth.Contract(Calc_ABI, contracts.CALC)
+ // 1450752979
+ console.log(await calc.methods.getQuote(contracts.WETH, 1e15, contracts.HEX, fee._30_per_10000).call())
+ })
+})
@@ -38,10 +38,10 @@ describe('Uniswap v3 test', () => {
gasLimit: 1e6
- let amountIn = 1e9
+ let amountIn = 1e15
let amountOutMin = 1
let deadline = parseInt(String(new Date().getTime() / 1e3)) + 60
- let path = [contracts.WETH, fee._5_per_10000, contracts.USDT]
+ let path = [contracts.WETH, fee._30_per_10000, contracts.HEX]
let to = deployer.address
let params = {
@@ -56,4 +56,4 @@ describe('Uniswap v3 test', () => {
.exactInput(params)
.send(rawTx).then(console.log)
})
-})