Skip to content

Commit

Permalink
Merge pull request #176 from 1inch/feature/no-gas-limit
Browse files Browse the repository at this point in the history
[SC-1387] Remove gas usage limitation by using all available gas
  • Loading branch information
galekseev authored Jan 27, 2025
2 parents 0268e85 + ec56086 commit 5bdc603
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions contracts/libraries/SafeERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ library SafeERC20 {
// Uniswap Permit2 address
address private constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;
bytes4 private constant _PERMIT_LENGTH_ERROR = 0x68275857; // SafePermitBadLength.selector
uint256 private constant _RAW_CALL_GAS_LIMIT = 5000;

/**
* @notice Fetches the balance of a specific ERC20 token held by an account.
Expand Down Expand Up @@ -483,7 +482,7 @@ library SafeERC20 {
safeWithdraw(weth, amount);
if (to != address(this)) {
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
if iszero(call(_RAW_CALL_GAS_LIMIT, to, amount, 0, 0, 0, 0)) {
if iszero(call(gas(), to, amount, 0, 0, 0, 0)) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
Expand Down
5 changes: 2 additions & 3 deletions contracts/libraries/UniERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ library UniERC20 {
error ToIsNotThis();
error ETHTransferFailed();

uint256 private constant _RAW_CALL_GAS_LIMIT = 5000;
IERC20 private constant _ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
IERC20 private constant _ZERO_ADDRESS = IERC20(address(0));

Expand Down Expand Up @@ -66,7 +65,7 @@ library UniERC20 {
if (isETH(token)) {
if (address(this).balance < amount) revert InsufficientBalance();
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{value: amount, gas: _RAW_CALL_GAS_LIMIT}("");
(bool success, ) = to.call{value: amount}("");
if (!success) revert ETHTransferFailed();
} else {
token.safeTransfer(to, amount);
Expand Down Expand Up @@ -97,7 +96,7 @@ library UniERC20 {
// Return remainder if exist
unchecked {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = from.call{value: msg.value - amount, gas: _RAW_CALL_GAS_LIMIT}("");
(bool success, ) = from.call{value: msg.value - amount}("");
if (!success) revert ETHTransferFailed();
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1inch/solidity-utils",
"version": "6.3.2",
"version": "6.4.0",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"exports": {
Expand Down

0 comments on commit 5bdc603

Please sign in to comment.