Hardcoded wethContract

This commit is contained in:
Thrilok Kumar 2021-06-18 14:25:16 +05:30
parent 32666224cf
commit 667241cf0b
2 changed files with 14 additions and 9 deletions

View File

@ -0,0 +1,8 @@
pragma solidity ^0.7.0;
import { TokenInterface } from "../../common/interfaces.sol";
abstract contract Helpers {
TokenInterface wethContract = TokenInterface(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
}

View File

@ -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);