mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fix
This commit is contained in:
parent
d96fae5728
commit
62899b3a6a
|
@ -114,7 +114,7 @@ contract Helpers {
|
|||
) public {
|
||||
IERC20(tokenIn).safeTransferFrom(sender, recipient, amountIn);
|
||||
|
||||
IERC20(tokenIn).safeApprove(address(router), amountIn);
|
||||
IERC20(tokenIn).safeApprove(recipient, amountIn);
|
||||
}
|
||||
|
||||
function swapSingleInput(ISwapRouter.ExactInputSingleParams memory params)
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
pragma solidity >=0.6.0;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
library TransferHelper {
|
||||
/// @notice Transfers tokens from the targeted address to the given destination
|
||||
/// @notice Errors with 'STF' if transfer fails
|
||||
/// @param token The contract address of the token to be transferred
|
||||
/// @param from The originating address from which the tokens will be transferred
|
||||
/// @param to The destination address of the transfer
|
||||
/// @param value The amount to be transferred
|
||||
function safeTransferFrom(
|
||||
address token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 value
|
||||
) internal {
|
||||
(bool success, bytes memory data) = token.call(
|
||||
abi.encodeWithSelector(
|
||||
IERC20.transferFrom.selector,
|
||||
from,
|
||||
to,
|
||||
value
|
||||
)
|
||||
);
|
||||
require(
|
||||
success && (data.length == 0 || abi.decode(data, (bool))),
|
||||
"STF"
|
||||
);
|
||||
}
|
||||
|
||||
/// @notice Transfers tokens from msg.sender to a recipient
|
||||
/// @dev Errors with ST if transfer fails
|
||||
/// @param token The contract address of the token which will be transferred
|
||||
/// @param to The recipient of the transfer
|
||||
/// @param value The value of the transfer
|
||||
function safeTransfer(
|
||||
address token,
|
||||
address to,
|
||||
uint256 value
|
||||
) internal {
|
||||
(bool success, bytes memory data) = token.call(
|
||||
abi.encodeWithSelector(IERC20.transfer.selector, to, value)
|
||||
);
|
||||
require(
|
||||
success && (data.length == 0 || abi.decode(data, (bool))),
|
||||
"ST"
|
||||
);
|
||||
}
|
||||
|
||||
/// @notice Approves the stipulated contract to spend the given allowance in the given token
|
||||
/// @dev Errors with 'SA' if transfer fails
|
||||
/// @param token The contract address of the token to be approved
|
||||
/// @param to The target of the approval
|
||||
/// @param value The amount of the given token the target will be allowed to spend
|
||||
function safeApprove(
|
||||
address token,
|
||||
address to,
|
||||
uint256 value
|
||||
) internal {
|
||||
(bool success, bytes memory data) = token.call(
|
||||
abi.encodeWithSelector(IERC20.approve.selector, to, value)
|
||||
);
|
||||
require(
|
||||
success && (data.length == 0 || abi.decode(data, (bool))),
|
||||
"SA"
|
||||
);
|
||||
}
|
||||
|
||||
/// @notice Transfers ETH to the recipient address
|
||||
/// @dev Fails with `STE`
|
||||
/// @param to The destination of the transfer
|
||||
/// @param value The value to be transferred
|
||||
function safeTransferETH(address to, uint256 value) internal {
|
||||
(bool success, ) = to.call{value: value}(new bytes(0));
|
||||
require(success, "STE");
|
||||
}
|
||||
}
|
|
@ -29,17 +29,22 @@ const WETH_ADDR = "0x82af49447d8a07e3bd95bd0d56f35241523fbab1";
|
|||
describe("Uniswap-sell-beta", function() {
|
||||
let UniswapSellBeta, uniswapSellBeta;
|
||||
before(async () => {
|
||||
const account = "0xa067668661c84476afcdc6fa5d758c4c01c34352";
|
||||
const account = "0x36cc7B13029B5DEe4034745FB4F24034f3F2ffc6";
|
||||
[owner, add1, add2] = await ethers.getSigners();
|
||||
|
||||
const tokenArtifact = await artifacts.readArtifact(
|
||||
"@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20"
|
||||
);
|
||||
const token = new ethers.Contract(
|
||||
WETH_ADDR,
|
||||
tokenArtifact.abi,
|
||||
ethers.provider
|
||||
);
|
||||
|
||||
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(),
|
||||
]);
|
||||
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
|
@ -47,10 +52,18 @@ describe("Uniswap-sell-beta", function() {
|
|||
});
|
||||
|
||||
const signer = await ethers.getSigner(account);
|
||||
console.log(await token.connect(signer).balanceOf(account));
|
||||
|
||||
const token = new ethers.Contract(
|
||||
WETH_ADDR,
|
||||
tokenArtifact.abi,
|
||||
ethers.provider
|
||||
);
|
||||
|
||||
console.log((await token.balanceOf(account)).toString());
|
||||
|
||||
await token
|
||||
.connect(signer)
|
||||
.transfer(owner.address, ethers.utils.parseUnits("0.00000001", 18));
|
||||
.transfer(owner.address, ethers.utils.parseEther("10"));
|
||||
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_stopImpersonatingAccount",
|
||||
|
@ -73,7 +86,7 @@ describe("Uniswap-sell-beta", function() {
|
|||
WETH_ADDR,
|
||||
USDC_ADDR,
|
||||
3000,
|
||||
ethers.utils.parseUnits("10.0"),
|
||||
ethers.utils.parseUnits("1.0", 18),
|
||||
0,
|
||||
true
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user