mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge pull request #43 from Instadapp/feat/weth-connector
Add WETH connector
This commit is contained in:
commit
9f360099e4
|
@ -43,7 +43,7 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
* @dev Gem Join address is ETH type collateral.
|
* @dev Gem Join address is ETH type collateral.
|
||||||
*/
|
*/
|
||||||
function isEth(address tknAddr) internal pure returns (bool) {
|
function isEth(address tknAddr) internal pure returns (bool) {
|
||||||
return tknAddr == ethAddr ? true : false;
|
return tknAddr == wethAddr ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@ pragma solidity ^0.7.0;
|
||||||
* @dev Collateralized Borrowing.
|
* @dev Collateralized Borrowing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TokenInterface } from "../../common/interfaces.sol";
|
import { TokenInterface, AccountInterface } from "../../common/interfaces.sol";
|
||||||
import { Helpers } from "./helpers.sol";
|
import { Helpers } from "./helpers.sol";
|
||||||
import { Events } from "./events.sol";
|
import { Events } from "./events.sol";
|
||||||
import { VatLike, TokenJoinInterface } from "./interface.sol";
|
import { VatLike, TokenJoinInterface } from "./interface.sol";
|
||||||
|
@ -44,6 +44,29 @@ abstract contract MakerResolver is Helpers, Events {
|
||||||
_eventParam = abi.encode(_vault, ilk);
|
_eventParam = abi.encode(_vault, ilk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Transfer Vault
|
||||||
|
* @notice Transfer a MakerDAO Vault to "nextOwner"
|
||||||
|
* @param vault Vault ID to close.
|
||||||
|
* @param nextOwner Address of the next owner of the vault.
|
||||||
|
*/
|
||||||
|
function transfer(
|
||||||
|
uint vault,
|
||||||
|
address nextOwner
|
||||||
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
require(AccountInterface(address(this)).isAuth(nextOwner), "nextOwner-is-not-auth");
|
||||||
|
|
||||||
|
uint256 _vault = getVault(vault);
|
||||||
|
(bytes32 ilk,) = getVaultData(_vault);
|
||||||
|
|
||||||
|
require(managerContract.owns(_vault) == address(this), "not-owner");
|
||||||
|
|
||||||
|
managerContract.give(_vault, nextOwner);
|
||||||
|
|
||||||
|
_eventName = "LogTransfer(uint256,bytes32,address)";
|
||||||
|
_eventParam = abi.encode(_vault, ilk, nextOwner);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Deposit ETH/ERC20_Token Collateral.
|
* @dev Deposit ETH/ERC20_Token Collateral.
|
||||||
* @notice Deposit collateral to a MakerDAO vault
|
* @notice Deposit collateral to a MakerDAO vault
|
||||||
|
@ -495,6 +518,6 @@ abstract contract MakerResolver is Helpers, Events {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV2Maker is MakerResolver {
|
contract ConnectV2MakerDAO is MakerResolver {
|
||||||
string public constant name = "MakerDao-v1";
|
string public constant name = "MakerDAO-v1.1";
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
* @dev Collateral Join address is ETH type collateral.
|
* @dev Collateral Join address is ETH type collateral.
|
||||||
*/
|
*/
|
||||||
function isEth(address tknAddr) internal pure returns (bool) {
|
function isEth(address tknAddr) internal pure returns (bool) {
|
||||||
return tknAddr == ethAddr ? true : false;
|
return tknAddr == wethAddr ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
6
contracts/mainnet/connectors/weth/events.sol
Normal file
6
contracts/mainnet/connectors/weth/events.sol
Normal 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);
|
||||||
|
}
|
8
contracts/mainnet/connectors/weth/helpers.sol
Normal file
8
contracts/mainnet/connectors/weth/helpers.sol
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
import { TokenInterface } from "../../common/interfaces.sol";
|
||||||
|
|
||||||
|
|
||||||
|
abstract contract Helpers {
|
||||||
|
TokenInterface constant internal wethContract = TokenInterface(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
|
||||||
|
}
|
65
contracts/mainnet/connectors/weth/main.sol
Normal file
65
contracts/mainnet/connectors/weth/main.sol
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Basic.
|
||||||
|
* @dev Deposit & Withdraw from DSA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
wethContract.approve(wethAddr, _amt);
|
||||||
|
wethContract.withdraw(_amt);
|
||||||
|
|
||||||
|
setUint(setId, _amt);
|
||||||
|
|
||||||
|
_eventName = "LogWithdraw(uint256,uint256,uint256)";
|
||||||
|
_eventParam = abi.encode(_amt, getId, setId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract ConnectV2WETH is Resolver {
|
||||||
|
string constant public name = "WETH-v1.0";
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
"BASIC-A": "0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687",
|
"BASIC-A": "0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687",
|
||||||
"COMP-A": "0xB446e325D44C52b93eC122Bf76301f235f90B9c9",
|
"COMP-A": "0xB446e325D44C52b93eC122Bf76301f235f90B9c9",
|
||||||
"COMPOUND-A": "0x911F4e4e762AeFA6F2Fc1b24e6B1A928200a88a8",
|
"COMPOUND-A": "0x911F4e4e762AeFA6F2Fc1b24e6B1A928200a88a8",
|
||||||
"MAKERDAO-A": "0x839c2D3aDe63DF5b0b8F3E57D5e145057Ab41556",
|
"MAKERDAO-A": "0x29AA7b765008b5dDbD687413B7F0D6E9d349F765",
|
||||||
"UNISWAP-A": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB",
|
"UNISWAP-A": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB",
|
||||||
"POLYGON-BRIDGE-A": "0x1b79B302132370B434fb7807b36CB72FB0510aD5",
|
"POLYGON-BRIDGE-A": "0x1b79B302132370B434fb7807b36CB72FB0510aD5",
|
||||||
"AAVE-CLAIM-A": "0x611C1FA59Aa1d6352c4C8bD44882063c6aEE85E0",
|
"AAVE-CLAIM-A": "0x611C1FA59Aa1d6352c4C8bD44882063c6aEE85E0",
|
||||||
|
@ -18,7 +18,8 @@
|
||||||
"AAVE-V2-IMPORT-B": "0x6fe05374924830B6aC98849f75A3D5766E51Ef10",
|
"AAVE-V2-IMPORT-B": "0x6fe05374924830B6aC98849f75A3D5766E51Ef10",
|
||||||
"COMPOUND-IMPORT-B": "0xdA101870ca6136539628F28041E1B55baf4EB6C0",
|
"COMPOUND-IMPORT-B": "0xdA101870ca6136539628F28041E1B55baf4EB6C0",
|
||||||
"INSTAPOOL-A": "0x5806Af7AB22E2916fA582Ff05731Bf7C682387B2",
|
"INSTAPOOL-A": "0x5806Af7AB22E2916fA582Ff05731Bf7C682387B2",
|
||||||
"MAKERDAO-CLAIM-A": "0x2f8cBE650af98602a215b6482F2aD60893C5A4E8"
|
"MAKERDAO-CLAIM-A": "0x2f8cBE650af98602a215b6482F2aD60893C5A4E8",
|
||||||
|
"WETH-A": "0x22075fa719eFb02Ca3cF298AFa9C974B7465E5D3"
|
||||||
},
|
},
|
||||||
"137" : {
|
"137" : {
|
||||||
"AAVE-V2-A": "0xE84d8010Afc3663919F44685cB53ED88866da3eE",
|
"AAVE-V2-A": "0xE84d8010Afc3663919F44685cB53ED88866da3eE",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user