From 667241cf0bb9ff45b59cfa0129936a2e2cba62e6 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 18 Jun 2021 14:25:16 +0530 Subject: [PATCH] Hardcoded wethContract --- contracts/mainnet/connectors/weth/helpers.sol | 8 ++++++++ contracts/mainnet/connectors/weth/main.sol | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 contracts/mainnet/connectors/weth/helpers.sol diff --git a/contracts/mainnet/connectors/weth/helpers.sol b/contracts/mainnet/connectors/weth/helpers.sol new file mode 100644 index 00000000..ad69ac7d --- /dev/null +++ b/contracts/mainnet/connectors/weth/helpers.sol @@ -0,0 +1,8 @@ +pragma solidity ^0.7.0; + +import { TokenInterface } from "../../common/interfaces.sol"; + + +abstract contract Helpers { + TokenInterface wethContract = TokenInterface(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); +} diff --git a/contracts/mainnet/connectors/weth/main.sol b/contracts/mainnet/connectors/weth/main.sol index 1f6d00b2..cbab1c6b 100644 --- a/contracts/mainnet/connectors/weth/main.sol +++ b/contracts/mainnet/connectors/weth/main.sol @@ -5,13 +5,12 @@ pragma solidity ^0.7.0; * @dev Deposit & Withdraw from DSA. */ -import { TokenInterface } from "../../common/interfaces.sol"; - import { DSMath } from "../../common/math.sol"; import { Basic } from "../../common/basic.sol"; import { Events } from "./events.sol"; +import { Helpers } from "./helpers.sol"; -abstract contract Resolver is Events, DSMath, Basic { +abstract contract Resolver is Events, DSMath, Basic, Helpers { /** * @dev Deposit ETH into WETH. @@ -27,9 +26,8 @@ abstract contract Resolver is Events, DSMath, Basic { ) public payable returns (string memory _eventName, bytes memory _eventParam) { uint _amt = getUint(getId, amt); - TokenInterface tokenContract = TokenInterface(wethAddr); _amt = _amt == uint(-1) ? address(this).balance : _amt; - tokenContract.deposit{value: _amt}(); + wethContract.deposit{value: _amt}(); setUint(setId, _amt); @@ -51,10 +49,9 @@ abstract contract Resolver is Events, DSMath, Basic { ) public payable returns (string memory _eventName, bytes memory _eventParam) { uint _amt = getUint(getId, amt); - TokenInterface tokenContract = TokenInterface(wethAddr); - _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(wethAddr, _amt); - tokenContract.withdraw(_amt); + _amt = _amt == uint(-1) ? wethContract.balanceOf(address(this)) : _amt; + wethContract.approve(wethAddr, _amt); + wethContract.withdraw(_amt); setUint(setId, _amt);