mirror of
https://github.com/Instadapp/dsa-connectors-2.0.git
synced 2024-07-29 21:57:39 +00:00
feat: added weeth contracts
This commit is contained in:
parent
258bfc4328
commit
de9956899a
7
contracts/mainnet/connectors/weeth/events.sol
Normal file
7
contracts/mainnet/connectors/weeth/events.sol
Normal file
|
@ -0,0 +1,7 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
contract Events {
|
||||
event LogDeposit(uint256 eETHAmount, uint256 weETHAmount, uint256 getId, uint256 setId);
|
||||
event LogWithdraw(uint256 weETHAmount, uint256 eETHAmount, uint256 getId, uint256 setId);
|
||||
}
|
10
contracts/mainnet/connectors/weeth/helpers.sol
Normal file
10
contracts/mainnet/connectors/weeth/helpers.sol
Normal file
|
@ -0,0 +1,10 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import "./interfaces.sol";
|
||||
import {TokenInterface} from "../../common/interfaces.sol";
|
||||
|
||||
contract Helpers{
|
||||
IWEETH constant weETHContract = IWEETH(0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee);
|
||||
TokenInterface constant eETHContract = TokenInterface(0x35fA164735182de50811E8e2E824cFb9B6118ac2);
|
||||
}
|
8
contracts/mainnet/connectors/weeth/interfaces.sol
Normal file
8
contracts/mainnet/connectors/weeth/interfaces.sol
Normal file
|
@ -0,0 +1,8 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
interface IWEETH{
|
||||
function balanceOf(address account) external view returns (uint256);
|
||||
function wrap(uint256 _eETHAmount) external returns (uint256);
|
||||
function unwrap(uint256 _weETHAmount) external returns (uint256);
|
||||
}
|
62
contracts/mainnet/connectors/weeth/main.sol
Normal file
62
contracts/mainnet/connectors/weeth/main.sol
Normal file
|
@ -0,0 +1,62 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import "./helpers.sol";
|
||||
import {Basic} from "../../common/basic.sol";
|
||||
|
||||
contract WEETHContract is Helpers, Basic {
|
||||
|
||||
/**
|
||||
* @dev Deposit eETH into weETH.
|
||||
* @notice Wrap eETH into weETH
|
||||
* @param eETHAmount The amount of eETH to deposit. (For max: `uint256(-1)`)
|
||||
* @param getId ID to retrieve eETH amount.
|
||||
* @param setId ID stores the amount of weETH deposited.
|
||||
*/
|
||||
function deposit(
|
||||
uint256 eETHAmount,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint256 _eETHAmount = getUint(getId, eETHAmount);
|
||||
_eETHAmount = _eETHAmount == type(uint256).max
|
||||
? eETHContract.balanceOf(address(this))
|
||||
: _eETHAmount;
|
||||
|
||||
approve(eETHContract, address(weETHContract), _eETHAmount);
|
||||
uint256 _weETHAmount = weETHContract.wrap(_eETHAmount);
|
||||
|
||||
setUint(setId, _weETHAmount);
|
||||
|
||||
_eventName = "LogDeposit(uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(_eETHAmount, _weETHAmount, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Withdraw eETH from weETH from Smart Account
|
||||
* @notice Unwrap eETH from weETH
|
||||
* @param weETHAmount The amount of weETH to withdraw. (For max: `uint256(-1)`)
|
||||
* @param getId ID to retrieve weETH amount.
|
||||
* @param setId ID stores the amount of eETH.
|
||||
*/
|
||||
function withdraw(
|
||||
uint256 weETHAmount,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint256 _weETHAmount = getUint(getId, weETHAmount);
|
||||
_weETHAmount = _weETHAmount == type(uint256).max
|
||||
? weETHContract.balanceOf(address(this))
|
||||
: _weETHAmount;
|
||||
|
||||
uint256 _eETHAmount = weETHContract.unwrap(_weETHAmount);
|
||||
setUint(setId, _eETHAmount);
|
||||
|
||||
_eventName = "LogWithdraw(uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(_weETHAmount, _eETHAmount, getId, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2WEETH is WEETHContract {
|
||||
string public constant name = "WEETH-v1.0";
|
||||
}
|
0
test/mainnet/weeth/weeth.test.ts
Normal file
0
test/mainnet/weeth/weeth.test.ts
Normal file
Loading…
Reference in New Issue
Block a user