Merge pull request #86 from Instadapp/weth-arbitrum-deployment

[Arbitrum] WETH connector
This commit is contained in:
Samyak Jain 2021-09-24 02:25:26 +05:30 committed by GitHub
commit 390ba737ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 1 deletions

View File

@ -0,0 +1,6 @@
pragma solidity ^0.7.0;
contract Events {
event LogDeposit(uint256 tokenAmt, uint256 getId, uint256 setId);
event LogWithdraw(uint256 tokenAmt, uint256 getId, uint256 setId);
}

View File

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

View File

@ -0,0 +1,65 @@
pragma solidity ^0.7.0;
/**
* @title WETH.
* @dev Wrap and Unwrap WETH.
*/
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, Helpers {
/**
* @dev Deposit ETH into WETH.
* @notice Wrap ETH into WETH
* @param amt The amount of ETH to deposit. (For max: `uint256(-1)`)
* @param getId ID to retrieve amt.
* @param setId ID stores the amount of ETH deposited.
*/
function deposit(
uint256 amt,
uint256 getId,
uint256 setId
) public payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
_amt = _amt == uint(-1) ? address(this).balance : _amt;
wethContract.deposit{value: _amt}();
setUint(setId, _amt);
_eventName = "LogDeposit(uint256,uint256,uint256)";
_eventParam = abi.encode(_amt, getId, setId);
}
/**
* @dev Withdraw ETH from WETH from Smart Account
* @notice Unwrap ETH from WETH
* @param amt The amount of weth to withdraw. (For max: `uint256(-1)`)
* @param getId ID to retrieve amt.
* @param setId ID stores the amount of ETH withdrawn.
*/
function withdraw(
uint amt,
uint getId,
uint setId
) public payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
_amt = _amt == uint(-1) ? wethContract.balanceOf(address(this)) : _amt;
approve(wethContract, wethAddr, _amt);
wethContract.withdraw(_amt);
setUint(setId, _amt);
_eventName = "LogWithdraw(uint256,uint256,uint256)";
_eventParam = abi.encode(_amt, getId, setId);
}
}
contract ConnectV2WETHArbitrum is Resolver {
string constant public name = "WETH-v1.0";
}

View File

@ -45,7 +45,8 @@
"BASIC-B": "0xa9b99766e6c676cf1975c0d3166f96c0848ff5ad", "BASIC-B": "0xa9b99766e6c676cf1975c0d3166f96c0848ff5ad",
"BASIC-C": "0x839c2d3ade63df5b0b8f3e57d5e145057ab41556", "BASIC-C": "0x839c2d3ade63df5b0b8f3e57d5e145057ab41556",
"UNISWAP-V3-A": "0x3254Ce8f5b1c82431B8f21Df01918342215825C2", "UNISWAP-V3-A": "0x3254Ce8f5b1c82431B8f21Df01918342215825C2",
"1INCH-A": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB" "1INCH-A": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB",
"WETH-A": "0x6C7256cf7C003dD85683339F75DdE9971f98f2FD"
} }
}, },
"mappings": { "mappings": {