Skip to content

Commit

Permalink
gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 22, 2024
1 parent 2d82f6c commit e815844
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions examples/swap/contracts/Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract Swap is UniversalContract {
address public immutable uniswapRouter;
GatewayZEVM public gateway;
uint256 constant BITCOIN = 18332;
uint256 public gasLimit;

Check warning

Code scanning / Slither

State variables that could be declared immutable Warning

Swap.gasLimit should be immutable

error InvalidAddress();
error Unauthorized();
Expand All @@ -24,11 +25,16 @@ contract Swap is UniversalContract {
_;
}

constructor(address payable gatewayAddress, address uniswapRouterAddress) {
constructor(
address payable gatewayAddress,
address uniswapRouterAddress,
uint256 gasLimitAmount
) {
if (gatewayAddress == address(0) || uniswapRouterAddress == address(0))
revert InvalidAddress();
uniswapRouter = uniswapRouterAddress;
gateway = GatewayZEVM(gatewayAddress);
gasLimit = gasLimitAmount;
}

struct Params {
Expand Down Expand Up @@ -123,7 +129,7 @@ contract Swap is UniversalContract {
callOnRevert: true,
abortAddress: address(0),
revertMessage: abi.encode(sender, inputToken),
onRevertGasLimit: 100000
onRevertGasLimit: gasLimit
})
);
}

Check warning

Code scanning / Slither

Unused return Medium

Check warning

Code scanning / Slither

Unused return Medium

Expand All @@ -147,7 +153,7 @@ contract Swap is UniversalContract {
callOnRevert: false,
abortAddress: address(0),
revertMessage: "",
onRevertGasLimit: 0
onRevertGasLimit: gasLimit
})
);
}
Expand Down
12 changes: 9 additions & 3 deletions examples/swap/contracts/SwapToAnyToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ contract SwapToAnyToken is UniversalContract {
address public immutable uniswapRouter;
GatewayZEVM public gateway;
uint256 constant BITCOIN = 18332;
uint256 public gasLimit;

Check warning

Code scanning / Slither

State variables that could be declared immutable Warning

SwapToAnyToken.gasLimit should be immutable

error InvalidAddress();
error Unauthorized();
Expand All @@ -25,11 +26,16 @@ contract SwapToAnyToken is UniversalContract {
_;
}

constructor(address payable gatewayAddress, address uniswapRouterAddress) {
constructor(
address payable gatewayAddress,
address uniswapRouterAddress,
uint256 gasLimitAmount
) {
if (gatewayAddress == address(0) || uniswapRouterAddress == address(0))
revert InvalidAddress();
uniswapRouter = uniswapRouterAddress;
gateway = GatewayZEVM(gatewayAddress);
gasLimit = gasLimitAmount;
}

struct Params {
Expand Down Expand Up @@ -163,7 +169,7 @@ contract SwapToAnyToken is UniversalContract {
callOnRevert: true,
abortAddress: address(0),
revertMessage: abi.encode(sender, inputToken),
onRevertGasLimit: 0
onRevertGasLimit: gasLimit
})
);
} else {
Expand Down Expand Up @@ -194,7 +200,7 @@ contract SwapToAnyToken is UniversalContract {
callOnRevert: false,
abortAddress: address(0),
revertMessage: "",
onRevertGasLimit: 0
onRevertGasLimit: gasLimit
})
);
}
Expand Down

0 comments on commit e815844

Please sign in to comment.