const CLAIM_ABI = [ { type: "function", stateMutability: "nonpayable", outputs: [], name: "claim", inputs: [ { type: "address", name: "_user", internalType: "address" }, { type: "address[]", name: "_tokens", internalType: "address[]" }, ], }, ]; const account = Ethers.send("eth_requestAccounts", [])[0]; const { loading, market, dapp, onSuccess, onError } = props; if (!loading || !dapp.incentiveController || !account || !market.allPools) return ""; const CollateralContract = new ethers.Contract( dapp.incentiveController, CLAIM_ABI, Ethers.provider().getSigner() ); const claimFn = (gasLimit) => { CollateralContract.claim(account, market.allPools, { gasLimit: gasLimit || 4000000, }) .then((tx) => { tx.wait().then((res) => { onSuccess(res); }); }) .catch((err) => { onError(err); }); }; // fix#DAP-800 CollateralContract.estimateGas.claim(account, market.allPools) .then((gas) => { claimFn(gas); }) .catch((err) => { console.log("Lendle claim estimate gas failed: ", err); claimFn(); }); return "";