I have this error when I try to deploy the deposit contract I have for a liquidity mining program, as Sushiswap
does it.
This is my deposit.js
file:
const { ethers } = require("hardhat");
const { USER_INITIAL_TOKEN_BALANCE } = require("../utils/config");
const getContracts = require("./deployedContracts");
const USER_LIQUIDITY_WETH_FUJI = ethers.utils.parseEther("0.05");
async function main() {
const [user] = await ethers.getSigners();
const { wallet, sushi } = await getContracts();
const tokenToDeposit = USER_INITIAL_TOKEN_BALANCE.mul(2);
// approve tokens to wallet
await sushi.connect(user).approve(wallet.address, tokenToDeposit);
// make deposit with ETH
const tx = await wallet
.connect(user)
.deposit(
[sushi.address],
[tokenToDeposit],
tokenToDeposit.mul(95).div(100),
USER_LIQUIDITY_WETH_FUJI.mul(95).div(100),
0,
{ value: USER_LIQUIDITY_WETH_FUJI, gasLimit: 1e6 }
);
console.log("sending TX: ", tx.hash);
const rc = await tx.wait();
console.log("confirmed at block: ", rc.blockNumber);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
my config.js
:
const { ethers } = require("hardhat");
exports.UNISWAP_INITIAL_TOKEN_RESERVE = ethers.utils.parseEther("10000");
exports.UNISWAP_INITIAL_WETH_RESERVE = ethers.utils.parseEther("100");
exports.USER_LIQUIDITY_WETH = ethers.utils.parseEther("1");
exports.USER_LIQUIDITY_SUSHI = ethers.utils.parseEther("100");
exports.USER_INITIAL_TOKEN_BALANCE = ethers.utils.parseEther("1000");
exports.UNISWAP_INITIAL_WETH_RESERVE_FUJI = ethers.utils.parseEther("0.25");
and finally my deployedContracts.js
:
require("dotenv").config();
const { ethers } = require("hardhat");
const sushiAbi = require("@sushiswap/core/abi/SushiToken.json");
const chefAbi = require("@sushiswap/core/abi/MasterChef.json");
const routerAbi =
require("@uniswap/v2-periphery/build/UniswapV2Router02.json").abi;
const pairAbi = require("@uniswap/v2-core/build/UniswapV2Pair.json").abi;
const walletAbi =
require("../artifacts/contracts/SushiWallet.sol/SushiWallet.json").abi;
async function getContracts() {
const [deployer, user] = await ethers.getSigners();
const provider = ethers.provider; // Obtain the ethers (provider)
const sushi = new ethers.Contract(
process.env.SUSHI_ADDRESS_FUJI,
sushiAbi,
provider // Passing the (provider) to the sushi contract
);
const router = new ethers.Contract(
process.env.ROUTER_ADDRESS_FUJI,
routerAbi,
provider // Passing the (provider) to the router contract
);
const pair = new ethers.Contract(
process.env.PAIR_ADDRESS_FUJI,
pairAbi,
provider // Passing the (provider) to the pair contract
);
const chef = new ethers.Contract(
process.env.MASTER_CHEF_ADDRESS_FUJI,
chefAbi,
provider // Passing the (provider) to the chef contract
);
const wallet = new ethers.Contract(
process.env.WALLET_ADDRESS_FUJI,
walletAbi,
provider // Passing the (provider) to the wallet contract
);
return {
sushi,
router,
pair,
chef,
wallet,
provider, // Add the (provider) to the returned object
};
}
module.exports = getContracts;
Actually I have done the functions step by step:
1. Deploy all contracts
- Factory
- WETH
- Sushi Contract
- Router
- MasterChef
- Sushi Wallet
2. Mint
- 1,000 SushiToken (SUSHI)
- 10,000 SushiToken (SUSHI)
3. Add Liquidity
10,000 SushiToken (SUSHI)
0.25 Wrapped ETH
0.0000000000000000001 UniswapV2
49.999999999999999999999999999 UniswapV2
4. Add Pool
- TransferOwnership
- Add
And then comes the deposit
which is where I get the following error when I want to deploy it:
5. Deposit:
Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0x27940d480dd8d3a518056bb6d4d530f7cceaee0eefdecb9c095c8d13db541790", transaction={"hash":"0x27940d480dd8d3a518056bb6d4d530f7cceaee0eefdecb9c095c8d13db541790","type":0,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0xd6dcB48f2Cd0F95651cAf2AfBFE82cE87Bd73073","gasPrice":{"type":"BigNumber","hex":"0x05d21dba00"},"gasLimit":{"type":"BigNumber","hex":"0x0f4240"},"to":"0x8598a0def8fc17a6F66b32dBC4D8C9f01b038Ba4","value":{"type":"BigNumber","hex":"0xb1a2bc2ec50000"},"nonce":57,"data":"0xca34a6ed00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000066ffcbfd5e5a30000000000000000000000000000000000000000000000000000000a8c0ff92d4c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000fb7612290f093d4d92d103464eea64658b3385e2000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000006c6b935b8bbd400000","r":"0x6fdd1295d5eb13aa4e57aebfc428bfa7667097eecab457f49fd0852bb457af80","s":"0x0eda3200b4c4683a9846b6be91e5ac2dca8bd747a458b93fe594f8c6e5278993","v":86262,"creates":null,"chainId":43113}, receipt={"to":"0x8598a0def8fc17a6F66b32dBC4D8C9f01b038Ba4","from":"0xd6dcB48f2Cd0F95651cAf2AfBFE82cE87Bd73073","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x83ae"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x9841bc02125390a43f89bc2fee5c047ae7c6031f2f6270bd619f29d108ed706b","transactionHash":"0x27940d480dd8d3a518056bb6d4d530f7cceaee0eefdecb9c095c8d13db541790","logs":[],"blockNumber":23219678,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x83ae"},"effectiveGasPrice":{"type":"BigNumber","hex":"0x05d21dba00"},"status":0,"type":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.6.2)
at Logger.makeError (/home/luis/Desktop/sushi-wallet/node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
at Logger.throwError (/home/luis/Desktop/sushi-wallet/node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
at EthersProviderWrapper.<anonymous> (/home/luis/Desktop/sushi-wallet/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1532:24)
at step (/home/luis/Desktop/sushi-wallet/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
at Object.next (/home/luis/Desktop/sushi-wallet/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
at fulfilled (/home/luis/Desktop/sushi-wallet/node_modules/@ethersproject/providers/lib/base-provider.js:20:58) {
reason: 'transaction failed',
code: 'CALL_EXCEPTION',
transactionHash: '0x27940d480dd8d3a518056bb6d4d530f7cceaee0eefdecb9c095c8d13db541790',
transaction: {
hash: '0x27940d480dd8d3a518056bb6d4d530f7cceaee0eefdecb9c095c8d13db541790',
type: 0,
accessList: null,
blockHash: null,
blockNumber: null,
transactionIndex: null,
confirmations: 0,
from: '0xd6dcB48f2Cd0F95651cAf2AfBFE82cE87Bd73073',
gasPrice: BigNumber { value: "25000000000" },
gasLimit: BigNumber { value: "1000000" },
to: '0x8598a0def8fc17a6F66b32dBC4D8C9f01b038Ba4',
value: BigNumber { value: "50000000000000000" },
nonce: 57,
data: '0xca34a6ed00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000066ffcbfd5e5a30000000000000000000000000000000000000000000000000000000a8c0ff92d4c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000fb7612290f093d4d92d103464eea64658b3385e2000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000006c6b935b8bbd400000',
r: '0x6fdd1295d5eb13aa4e57aebfc428bfa7667097eecab457f49fd0852bb457af80',
s: '0x0eda3200b4c4683a9846b6be91e5ac2dca8bd747a458b93fe594f8c6e5278993',
v: 86262,
creates: null,
chainId: 43113,
wait: [Function (anonymous)]
},
receipt: {
to: '0x8598a0def8fc17a6F66b32dBC4D8C9f01b038Ba4',
from: '0xd6dcB48f2Cd0F95651cAf2AfBFE82cE87Bd73073',
contractAddress: null,
transactionIndex: 0,
gasUsed: BigNumber { value: "33710" },
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
blockHash: '0x9841bc02125390a43f89bc2fee5c047ae7c6031f2f6270bd619f29d108ed706b',
transactionHash: '0x27940d480dd8d3a518056bb6d4d530f7cceaee0eefdecb9c095c8d13db541790',
logs: [],
blockNumber: 23219678,
confirmations: 1,
cumulativeGasUsed: BigNumber { value: "33710" },
effectiveGasPrice: BigNumber { value: "25000000000" },
status: 0,
type: 0,
byzantium: true
}
}
Or I usually get a fee too low
error.
I do not know if the error is in a call from the script or comes from the intrinsic gas in the transaction. I hope you can help me! I would appreciate it !!! Thanks in advance