feat: Initial Setup
This commit is contained in:
122
evm/src/etherfi/EtherfiAdapter.sol
Normal file
122
evm/src/etherfi/EtherfiAdapter.sol
Normal file
@@ -0,0 +1,122 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
pragma experimental ABIEncoderV2;
|
||||
pragma solidity ^0.8.13;
|
||||
|
||||
import {IERC20, ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||
|
||||
/// @title Etherfi Adapter
|
||||
/// @dev This contract supports the following swaps: eETH<->ETH, wETH<->eETH, wETH<->ETH
|
||||
contract EtherfiAdapter is ISwapAdapter {
|
||||
|
||||
IWeEth wEeth;
|
||||
IeEth eEth;
|
||||
ILiquidityPool liquidityPool;
|
||||
|
||||
constructor(address _wEeth) {
|
||||
wEeth = IWeEth(_wEeth);
|
||||
eEth = wEeth.eETH();
|
||||
liquidityPool = eEth.liquidityPool();
|
||||
}
|
||||
|
||||
/// @dev Check if tokens in input are supported by this adapter
|
||||
modifier checkInputTokens(address sellToken, address buyToken) {
|
||||
if(sellToken == buyToken) {
|
||||
revert Unavailable("This pool only supports eETH, weEth and ETH");
|
||||
}
|
||||
if(sellToken != address(wEeth) && sellToken != address(eEth) && sellToken && sellToken != address(0)) {
|
||||
revert Unavailable("This pool only supports eETH, weEth and ETH");
|
||||
}
|
||||
if(buyToken != address(wEeth) && buyToken != address(eEth) && buyToken != address(0)) {
|
||||
revert Unavailable("This pool only supports eETH, weEth and ETH");
|
||||
}
|
||||
_;
|
||||
}
|
||||
|
||||
function price(
|
||||
bytes32 _poolId,
|
||||
IERC20 _sellToken,
|
||||
IERC20 _buyToken,
|
||||
uint256[] memory _specifiedAmounts
|
||||
) external view override returns (Fraction[] memory _prices) {
|
||||
revert NotImplemented("TemplateSwapAdapter.price");
|
||||
}
|
||||
|
||||
function swap(
|
||||
bytes32 poolId,
|
||||
IERC20 sellToken,
|
||||
IERC20 buyToken,
|
||||
OrderSide side,
|
||||
uint256 specifiedAmount
|
||||
) external returns (Trade memory trade) {
|
||||
revert NotImplemented("TemplateSwapAdapter.swap");
|
||||
}
|
||||
|
||||
function getLimits(bytes32 poolId, IERC20 sellToken, IERC20 buyToken)
|
||||
external
|
||||
returns (uint256[] memory limits)
|
||||
{
|
||||
revert NotImplemented("TemplateSwapAdapter.getLimits");
|
||||
}
|
||||
|
||||
function getCapabilities(bytes32 poolId, IERC20 sellToken, IERC20 buyToken)
|
||||
external
|
||||
returns (Capability[] memory capabilities)
|
||||
{
|
||||
revert NotImplemented("TemplateSwapAdapter.getCapabilities");
|
||||
}
|
||||
|
||||
function getTokens(bytes32 poolId)
|
||||
external
|
||||
returns (IERC20[] memory tokens)
|
||||
{
|
||||
revert NotImplemented("TemplateSwapAdapter.getTokens");
|
||||
}
|
||||
|
||||
function getPoolIds(uint256 offset, uint256 limit)
|
||||
external
|
||||
returns (bytes32[] memory ids)
|
||||
{
|
||||
revert NotImplemented("TemplateSwapAdapter.getPoolIds");
|
||||
}
|
||||
}
|
||||
|
||||
interface ILiquidityPool {
|
||||
|
||||
function numPendingDeposits() external view returns (uint32);
|
||||
function totalValueOutOfLp() external view returns (uint128);
|
||||
function totalValueInLp() external view returns (uint128);
|
||||
function getTotalEtherClaimOf(address _user) external view returns (uint256);
|
||||
function getTotalPooledEther() external view returns (uint256);
|
||||
function sharesForAmount(uint256 _amount) external view returns (uint256);
|
||||
function sharesForWithdrawalAmount(uint256 _amount) external view returns (uint256);
|
||||
function amountForShare(uint256 _share) external view returns (uint256);
|
||||
|
||||
function deposit() external payable returns (uint256);
|
||||
function deposit(address _referral) external payable returns (uint256);
|
||||
function deposit(address _user, address _referral) external payable returns (uint256);
|
||||
|
||||
}
|
||||
|
||||
interface IeEth {
|
||||
|
||||
function liquidityPool() external view returns (ILiquidityPool);
|
||||
|
||||
function totalShares() external view returns (uint256);
|
||||
|
||||
function shares(address _user) external view returns (uint256);
|
||||
|
||||
}
|
||||
|
||||
interface IWeEth {
|
||||
|
||||
function eETH() external view returns (IeEth);
|
||||
|
||||
function getWeETHByeETH(uint256 _eETHAmount) external view returns (uint256);
|
||||
|
||||
function getEETHByWeETH(uint256 _weETHAmount) external view returns (uint256);
|
||||
|
||||
function wrap(uint256 _eETHAmount) external returns (uint256);
|
||||
|
||||
function unwrap(uint256 _weETHAmount) external returns (uint256);
|
||||
|
||||
}
|
||||
36
evm/src/etherfi/manifest.yaml
Normal file
36
evm/src/etherfi/manifest.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
# information about the author helps us reach out in case of issues.
|
||||
author:
|
||||
name: Propellerheads.xyz
|
||||
email: alan@propellerheads.xyz
|
||||
|
||||
# Protocol Constants
|
||||
constants:
|
||||
protocol_gas: 30000
|
||||
# minimum capabilities we can expect, individual pools may extend these
|
||||
capabilities:
|
||||
- SellSide
|
||||
- BuySide
|
||||
- PriceFunction
|
||||
|
||||
# The file containing the adapter contract
|
||||
contract: EtherfiAdapter.sol
|
||||
|
||||
# Deployment instances used to generate chain specific bytecode.
|
||||
instances:
|
||||
- chain:
|
||||
name: mainnet
|
||||
id: 0
|
||||
arguments:
|
||||
- "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee"
|
||||
|
||||
# Specify some automatic test cases in case getPoolIds and
|
||||
# getTokens are not implemented.
|
||||
tests:
|
||||
instances:
|
||||
- pool_id: "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc"
|
||||
sell_token: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
||||
buy_token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
||||
block: 17000000
|
||||
chain:
|
||||
id: 0
|
||||
name: mainnet
|
||||
Reference in New Issue
Block a user