Fix merge issues
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
pragma solidity ^0.8.13;
|
||||
|
||||
import {IERC20, ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||
import {ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||
import {IERC20Metadata} from
|
||||
"openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
||||
import {SafeERC20} from
|
||||
"openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
|
||||
/// @dev custom reserve limit factor to prevent revert errors in OrderSide.Buy
|
||||
uint256 constant RESERVE_LIMIT_FACTOR = 10;
|
||||
@@ -16,6 +19,8 @@ uint256 constant STANDARD_TOKEN_DECIMALS = 10 ** 18;
|
||||
/// collateral, it will, because agEUR is minted, and this mechanism is used to
|
||||
/// stabilize the agEUR price.
|
||||
contract AngleAdapter is ISwapAdapter {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
ITransmuter immutable transmuter;
|
||||
|
||||
constructor(ITransmuter _transmuter) {
|
||||
@@ -30,7 +35,7 @@ contract AngleAdapter is ISwapAdapter {
|
||||
* architecture of Angle, it's not possible to calculate the storage
|
||||
* modifications of Angle inside the adapter.
|
||||
*/
|
||||
function price(bytes32, IERC20, IERC20, uint256[] memory)
|
||||
function price(bytes32, address, address, uint256[] memory)
|
||||
external
|
||||
pure
|
||||
override
|
||||
@@ -48,8 +53,8 @@ contract AngleAdapter is ISwapAdapter {
|
||||
*/
|
||||
function swap(
|
||||
bytes32,
|
||||
IERC20 sellToken,
|
||||
IERC20 buyToken,
|
||||
address sellToken,
|
||||
address buyToken,
|
||||
OrderSide side,
|
||||
uint256 specifiedAmount
|
||||
) external returns (Trade memory trade) {
|
||||
@@ -65,10 +70,10 @@ contract AngleAdapter is ISwapAdapter {
|
||||
}
|
||||
trade.gasUsed = gasBefore - gasleft();
|
||||
uint8 decimals = side == OrderSide.Sell
|
||||
? IERC20Metadata(address(sellToken)).decimals()
|
||||
: IERC20Metadata(address(buyToken)).decimals();
|
||||
? IERC20Metadata(sellToken).decimals()
|
||||
: IERC20Metadata(buyToken).decimals();
|
||||
trade.price =
|
||||
getPriceAt(address(sellToken), address(buyToken), side, decimals);
|
||||
getPriceAt(sellToken, buyToken, side, decimals);
|
||||
}
|
||||
|
||||
/// @inheritdoc ISwapAdapter
|
||||
@@ -79,50 +84,48 @@ contract AngleAdapter is ISwapAdapter {
|
||||
/// contract size, with an high complexity. In addition, we underestimate to
|
||||
/// RESERVE_LIMIT_FACTOR to ensure swaps with OrderSide.Buy won't fail
|
||||
/// anyway.
|
||||
function getLimits(bytes32, IERC20 sellToken, IERC20 buyToken)
|
||||
function getLimits(bytes32, address sellToken, address buyToken)
|
||||
external
|
||||
view
|
||||
override
|
||||
returns (uint256[] memory limits)
|
||||
{
|
||||
limits = new uint256[](2);
|
||||
address sellTokenAddress = address(sellToken);
|
||||
address buyTokenAddress = address(buyToken);
|
||||
address transmuterAddress = address(transmuter);
|
||||
|
||||
if (buyTokenAddress == transmuter.agToken()) {
|
||||
if (buyToken == transmuter.agToken()) {
|
||||
// mint(buy agToken)
|
||||
Collateral memory collatInfo =
|
||||
transmuter.getCollateralInfo(sellTokenAddress);
|
||||
transmuter.getCollateralInfo(sellToken);
|
||||
if (collatInfo.isManaged > 0) {
|
||||
limits[0] =
|
||||
LibManager.maxAvailable(collatInfo.managerData.config);
|
||||
} else {
|
||||
limits[0] = sellToken.balanceOf(transmuterAddress);
|
||||
limits[0] = IERC20(sellToken).balanceOf(transmuterAddress);
|
||||
}
|
||||
limits[1] =
|
||||
transmuter.quoteIn(limits[0], sellTokenAddress, buyTokenAddress);
|
||||
transmuter.quoteIn(limits[0], sellToken, buyToken);
|
||||
limits[1] = limits[1] / RESERVE_LIMIT_FACTOR;
|
||||
limits[0] = limits[0] / RESERVE_LIMIT_FACTOR;
|
||||
} else {
|
||||
// burn(sell agToken)
|
||||
Collateral memory collatInfo =
|
||||
transmuter.getCollateralInfo(buyTokenAddress);
|
||||
transmuter.getCollateralInfo(buyToken);
|
||||
if (collatInfo.isManaged > 0) {
|
||||
limits[1] =
|
||||
LibManager.maxAvailable(collatInfo.managerData.config);
|
||||
} else {
|
||||
limits[1] = buyToken.balanceOf(transmuterAddress);
|
||||
limits[1] = IERC20(buyToken).balanceOf(transmuterAddress);
|
||||
}
|
||||
limits[0] =
|
||||
transmuter.quoteIn(limits[1], buyTokenAddress, sellTokenAddress);
|
||||
transmuter.quoteIn(limits[1], buyToken, sellToken);
|
||||
limits[1] = limits[1] / RESERVE_LIMIT_FACTOR;
|
||||
limits[0] = limits[0] / RESERVE_LIMIT_FACTOR;
|
||||
}
|
||||
}
|
||||
|
||||
/// @inheritdoc ISwapAdapter
|
||||
function getCapabilities(bytes32, IERC20, IERC20)
|
||||
function getCapabilities(bytes32, address, address)
|
||||
external
|
||||
pure
|
||||
override
|
||||
@@ -141,14 +144,14 @@ contract AngleAdapter is ISwapAdapter {
|
||||
external
|
||||
view
|
||||
override
|
||||
returns (IERC20[] memory tokens)
|
||||
returns (address[] memory tokens)
|
||||
{
|
||||
address[] memory collateralsAddresses = transmuter.getCollateralList();
|
||||
tokens = new IERC20[](collateralsAddresses.length + 1);
|
||||
tokens = new address[](collateralsAddresses.length + 1);
|
||||
for (uint256 i = 0; i < collateralsAddresses.length; i++) {
|
||||
tokens[i] = IERC20(collateralsAddresses[i]);
|
||||
tokens[i] = address(collateralsAddresses[i]);
|
||||
}
|
||||
tokens[collateralsAddresses.length] = IERC20(transmuter.agToken());
|
||||
tokens[collateralsAddresses.length] = transmuter.agToken();
|
||||
}
|
||||
|
||||
function getPoolIds(uint256, uint256)
|
||||
@@ -189,17 +192,14 @@ contract AngleAdapter is ISwapAdapter {
|
||||
/// @param buyToken The token being bought.
|
||||
/// @param amount The amount to be traded.
|
||||
/// @return calculatedAmount The amount of tokens received.
|
||||
function sell(IERC20 sellToken, IERC20 buyToken, uint256 amount)
|
||||
function sell(address sellToken, address buyToken, uint256 amount)
|
||||
internal
|
||||
returns (uint256 calculatedAmount)
|
||||
{
|
||||
address sellTokenAddress = address(sellToken);
|
||||
address buyTokenAddress = address(buyToken);
|
||||
|
||||
sellToken.transferFrom(msg.sender, address(this), amount);
|
||||
sellToken.approve(address(transmuter), amount);
|
||||
IERC20(sellToken).safeTransferFrom(msg.sender, address(this), amount);
|
||||
IERC20(sellToken).approve(address(transmuter), amount);
|
||||
calculatedAmount = transmuter.swapExactInput(
|
||||
amount, 0, sellTokenAddress, buyTokenAddress, msg.sender, 0
|
||||
amount, 0, sellToken, buyToken, msg.sender, 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,22 +208,20 @@ contract AngleAdapter is ISwapAdapter {
|
||||
/// @param buyToken The token being bought.
|
||||
/// @param amountOut The amount of buyToken to receive.
|
||||
/// @return calculatedAmount The amount of tokens received.
|
||||
function buy(IERC20 sellToken, IERC20 buyToken, uint256 amountOut)
|
||||
function buy(address sellToken, address buyToken, uint256 amountOut)
|
||||
internal
|
||||
returns (uint256 calculatedAmount)
|
||||
{
|
||||
address sellTokenAddress = address(sellToken);
|
||||
address buyTokenAddress = address(buyToken);
|
||||
calculatedAmount =
|
||||
transmuter.quoteOut(amountOut, sellTokenAddress, buyTokenAddress);
|
||||
transmuter.quoteOut(amountOut, sellToken, buyToken);
|
||||
|
||||
sellToken.transferFrom(msg.sender, address(this), calculatedAmount);
|
||||
sellToken.approve(address(transmuter), calculatedAmount);
|
||||
IERC20(sellToken).safeTransferFrom(msg.sender, address(this), calculatedAmount);
|
||||
IERC20(sellToken).approve(address(transmuter), calculatedAmount);
|
||||
transmuter.swapExactOutput(
|
||||
amountOut,
|
||||
type(uint256).max,
|
||||
sellTokenAddress,
|
||||
buyTokenAddress,
|
||||
sellToken,
|
||||
buyToken,
|
||||
msg.sender,
|
||||
0
|
||||
);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
pragma solidity ^0.8.13;
|
||||
|
||||
import {IERC20, ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||
import {ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||
import {SafeERC20} from
|
||||
"openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
|
||||
@@ -54,39 +55,37 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
/// @inheritdoc ISwapAdapter
|
||||
function price(
|
||||
bytes32,
|
||||
IERC20 _sellToken,
|
||||
IERC20 _buyToken,
|
||||
uint256[] memory _specifiedAmounts
|
||||
address sellToken,
|
||||
address buyToken,
|
||||
uint256[] memory specifiedAmounts
|
||||
)
|
||||
external
|
||||
view
|
||||
override
|
||||
checkInputTokens(address(_sellToken), address(_buyToken))
|
||||
returns (Fraction[] memory _prices)
|
||||
checkInputTokens(sellToken, buyToken)
|
||||
returns (Fraction[] memory prices)
|
||||
{
|
||||
_prices = new Fraction[](_specifiedAmounts.length);
|
||||
address sellTokenAddress = address(_sellToken);
|
||||
address buyTokenAddress = address(_buyToken);
|
||||
prices = new Fraction[](specifiedAmounts.length);
|
||||
uint256 totalPooledEther = liquidityPool.getTotalPooledEther();
|
||||
uint256 eEthTotalShares = eEth.totalShares();
|
||||
|
||||
for (uint256 i = 0; i < _specifiedAmounts.length; i++) {
|
||||
if (sellTokenAddress == address(0)) {
|
||||
for (uint256 i = 0; i < specifiedAmounts.length; i++) {
|
||||
if (sellToken == address(0)) {
|
||||
uint256 sharesForDepositAmount = _sharesForDepositAmount(
|
||||
_specifiedAmounts[i], totalPooledEther, eEthTotalShares
|
||||
specifiedAmounts[i], totalPooledEther, eEthTotalShares
|
||||
);
|
||||
_prices[i] = getPriceAt(
|
||||
sellTokenAddress,
|
||||
buyTokenAddress,
|
||||
_specifiedAmounts[i],
|
||||
totalPooledEther + _specifiedAmounts[i],
|
||||
prices[i] = getPriceAt(
|
||||
sellToken,
|
||||
buyToken,
|
||||
specifiedAmounts[i],
|
||||
totalPooledEther + specifiedAmounts[i],
|
||||
eEthTotalShares + sharesForDepositAmount
|
||||
);
|
||||
} else {
|
||||
_prices[i] = getPriceAt(
|
||||
sellTokenAddress,
|
||||
buyTokenAddress,
|
||||
_specifiedAmounts[i],
|
||||
prices[i] = getPriceAt(
|
||||
sellToken,
|
||||
buyToken,
|
||||
specifiedAmounts[i],
|
||||
totalPooledEther,
|
||||
eEthTotalShares
|
||||
);
|
||||
@@ -97,31 +96,28 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
/// @inheritdoc ISwapAdapter
|
||||
function swap(
|
||||
bytes32,
|
||||
IERC20 sellToken,
|
||||
IERC20 buyToken,
|
||||
address sellToken,
|
||||
address buyToken,
|
||||
OrderSide side,
|
||||
uint256 specifiedAmount
|
||||
)
|
||||
external
|
||||
override
|
||||
checkInputTokens(address(sellToken), address(buyToken))
|
||||
checkInputTokens(sellToken, buyToken)
|
||||
returns (Trade memory trade)
|
||||
{
|
||||
if (specifiedAmount == 0) {
|
||||
return trade;
|
||||
}
|
||||
|
||||
address sellTokenAddress = address(sellToken);
|
||||
address buyTokenAddress = address(buyToken);
|
||||
uint256 gasBefore = gasleft();
|
||||
if (sellTokenAddress == address(0)) {
|
||||
if (buyTokenAddress == address(eEth)) {
|
||||
if (sellToken == address(0)) {
|
||||
if (buyToken == address(eEth)) {
|
||||
trade.calculatedAmount = swapEthForEeth(specifiedAmount, side);
|
||||
} else {
|
||||
trade.calculatedAmount = swapEthForWeEth(specifiedAmount, side);
|
||||
}
|
||||
} else {
|
||||
if (sellTokenAddress == address(eEth)) {
|
||||
if (sellToken == address(eEth)) {
|
||||
trade.calculatedAmount = swapEethForWeEth(specifiedAmount, side);
|
||||
} else {
|
||||
trade.calculatedAmount = swapWeEthForEeth(specifiedAmount, side);
|
||||
@@ -134,8 +130,8 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
/// amount(PRECISE_UNIT) to render a well-formatted price without
|
||||
/// precisions loss
|
||||
trade.price = getPriceAt(
|
||||
sellTokenAddress,
|
||||
buyTokenAddress,
|
||||
sellToken,
|
||||
buyToken,
|
||||
PRECISE_UNIT,
|
||||
liquidityPool.getTotalPooledEther(),
|
||||
eEth.totalShares()
|
||||
@@ -143,11 +139,11 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
}
|
||||
|
||||
/// @inheritdoc ISwapAdapter
|
||||
function getLimits(bytes32, IERC20 sellToken, IERC20 buyToken)
|
||||
function getLimits(bytes32, address sellToken, address buyToken)
|
||||
external
|
||||
view
|
||||
override
|
||||
checkInputTokens(address(sellToken), address(buyToken))
|
||||
checkInputTokens(sellToken, buyToken)
|
||||
returns (uint256[] memory limits)
|
||||
{
|
||||
limits = new uint256[](2);
|
||||
@@ -155,8 +151,8 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
/// @dev Limits are underestimated to 90% of totalSupply as both weEth
|
||||
/// and eEth have no limits but revert in some cases
|
||||
if (
|
||||
address(sellToken) == address(weEth)
|
||||
|| address(buyToken) == address(weEth)
|
||||
sellToken == address(weEth)
|
||||
|| buyToken == address(weEth)
|
||||
) {
|
||||
limits[0] = IERC20(address(weEth)).totalSupply() * 90 / 100;
|
||||
} else {
|
||||
@@ -166,7 +162,7 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
}
|
||||
|
||||
/// @inheritdoc ISwapAdapter
|
||||
function getCapabilities(bytes32, IERC20, IERC20)
|
||||
function getCapabilities(bytes32, address, address)
|
||||
external
|
||||
pure
|
||||
override
|
||||
@@ -183,12 +179,12 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
external
|
||||
view
|
||||
override
|
||||
returns (IERC20[] memory tokens)
|
||||
returns (address[] memory tokens)
|
||||
{
|
||||
tokens = new IERC20[](3);
|
||||
tokens[0] = IERC20(address(0));
|
||||
tokens[1] = IERC20(address(eEth));
|
||||
tokens[2] = IERC20(address(weEth));
|
||||
tokens = new address[](3);
|
||||
tokens[0] = address(0);
|
||||
tokens[1] = address(eEth);
|
||||
tokens[2] = address(weEth);
|
||||
}
|
||||
|
||||
/// @inheritdoc ISwapAdapter
|
||||
@@ -217,7 +213,7 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
uint256 receivedAmount = liquidityPool.deposit{value: amount}();
|
||||
uint256 balBeforeUser =
|
||||
IERC20(address(eEth)).balanceOf(address(msg.sender));
|
||||
IERC20(address(eEth)).transfer(msg.sender, receivedAmount);
|
||||
IERC20(address(eEth)).safeTransfer(msg.sender, receivedAmount);
|
||||
return IERC20(address(eEth)).balanceOf(address(msg.sender))
|
||||
- balBeforeUser;
|
||||
}
|
||||
@@ -317,7 +313,7 @@ contract EtherfiAdapter is ISwapAdapter {
|
||||
uint256 receivedAmount = weEth.unwrap(amount);
|
||||
uint256 balBeforeUser =
|
||||
IERC20(address(eEth)).balanceOf(address(msg.sender));
|
||||
IERC20(address(eEth)).transfer(msg.sender, receivedAmount);
|
||||
IERC20(address(eEth)).safeTransfer(msg.sender, receivedAmount);
|
||||
return IERC20(address(eEth)).balanceOf(address(msg.sender))
|
||||
- balBeforeUser;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, EURC, agEUR);
|
||||
uint256[] memory limits = adapter.getLimits(pair, address(EURC), address(agEUR));
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 0);
|
||||
@@ -54,7 +54,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 agEUR_balance = agEUR.balanceOf(address(this));
|
||||
|
||||
Trade memory trade =
|
||||
adapter.swap(pair, EURC, agEUR, side, specifiedAmount);
|
||||
adapter.swap(pair, address(EURC), address(agEUR), side, specifiedAmount);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
if (side == OrderSide.Buy) {
|
||||
@@ -85,7 +85,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, agEUR, EURC);
|
||||
uint256[] memory limits = adapter.getLimits(pair, address(agEUR), address(EURC));
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 0);
|
||||
@@ -103,7 +103,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 agEUR_balance = agEUR.balanceOf(address(this));
|
||||
|
||||
Trade memory trade =
|
||||
adapter.swap(pair, agEUR, EURC, side, specifiedAmount);
|
||||
adapter.swap(pair, address(agEUR), address(EURC), side, specifiedAmount);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
if (side == OrderSide.Buy) {
|
||||
@@ -154,7 +154,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
||||
deal(address(agEUR), address(this), type(uint256).max);
|
||||
agEUR.approve(address(adapter), type(uint256).max);
|
||||
}
|
||||
trades[i] = adapter.swap(pair, agEUR, EURC, side, amounts[i]);
|
||||
trades[i] = adapter.swap(pair, address(agEUR), address(EURC), side, amounts[i]);
|
||||
vm.revertTo(beforeSwap);
|
||||
}
|
||||
|
||||
@@ -174,20 +174,20 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
||||
public
|
||||
{
|
||||
Capability[] memory res =
|
||||
adapter.getCapabilities(pair, IERC20(t0), IERC20(t1));
|
||||
adapter.getCapabilities(pair, t0, t1);
|
||||
|
||||
assertEq(res.length, 2);
|
||||
}
|
||||
|
||||
function testGetTokensAngle() public {
|
||||
IERC20[] memory tokens = adapter.getTokens(bytes32(0));
|
||||
address[] memory tokens = adapter.getTokens(bytes32(0));
|
||||
|
||||
assertGe(tokens.length, 2);
|
||||
}
|
||||
|
||||
function testGetLimitsAngle() public {
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, agEUR, EURC);
|
||||
uint256[] memory limits = adapter.getLimits(pair, address(agEUR), address(EURC));
|
||||
|
||||
assertEq(limits.length, 2);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
function testPriceFuzzEtherfi(uint256 amount0, uint256 amount1) public {
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(
|
||||
pair, IERC20(address(weEth)), IERC20(address(eEth))
|
||||
pair, address(address(weEth)), address(address(eEth))
|
||||
);
|
||||
vm.assume(amount0 < limits[0] && amount0 > 0);
|
||||
vm.assume(amount1 < limits[1] && amount1 > 0);
|
||||
@@ -41,7 +41,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
amounts[1] = amount1;
|
||||
|
||||
Fraction[] memory prices = adapter.price(
|
||||
pair, IERC20(address(weEth)), IERC20(address(eEth)), amounts
|
||||
pair, address(address(weEth)), address(address(eEth)), amounts
|
||||
);
|
||||
|
||||
for (uint256 i = 0; i < prices.length; i++) {
|
||||
@@ -58,7 +58,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
IERC20 eEth_ = IERC20(address(eEth));
|
||||
IERC20 weEth_ = IERC20(address(weEth));
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, eEth_, weEth_);
|
||||
uint256[] memory limits = adapter.getLimits(pair, address(eEth_), address(weEth_));
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 100);
|
||||
@@ -67,7 +67,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
/// work(balance is shares)
|
||||
deal(address(adapter), type(uint256).max);
|
||||
adapter.swap(
|
||||
pair, IERC20(address(0)), eEth_, OrderSide.Buy, limits[0]
|
||||
pair, address(address(0)), address(eEth_), OrderSide.Buy, limits[0]
|
||||
);
|
||||
|
||||
eEth_.approve(address(adapter), type(uint256).max);
|
||||
@@ -78,7 +78,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
/// work(balance is shares)
|
||||
deal(address(adapter), type(uint128).max);
|
||||
adapter.swap(
|
||||
pair, IERC20(address(0)), eEth_, OrderSide.Buy, specifiedAmount
|
||||
pair, address(address(0)), address(eEth_), OrderSide.Buy, specifiedAmount
|
||||
);
|
||||
|
||||
eEth_.approve(address(adapter), specifiedAmount);
|
||||
@@ -88,7 +88,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 weEth_balance = weEth_.balanceOf(address(this));
|
||||
|
||||
Trade memory trade =
|
||||
adapter.swap(pair, eEth_, weEth_, side, specifiedAmount);
|
||||
adapter.swap(pair, address(eEth_), address(weEth_), side, specifiedAmount);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
if (side == OrderSide.Buy) {
|
||||
@@ -140,7 +140,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
IERC20 weEth_ = IERC20(address(weEth));
|
||||
uint256 weEth_bal_before = weEth_.balanceOf(address(this));
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, weEth_, eEth_);
|
||||
uint256[] memory limits = adapter.getLimits(pair, address(weEth_), address(eEth_));
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 100);
|
||||
@@ -149,7 +149,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
/// work(balance is shares)
|
||||
deal(address(adapter), type(uint256).max);
|
||||
adapter.swap(
|
||||
pair, IERC20(address(0)), weEth_, OrderSide.Buy, limits[0]
|
||||
pair, address(address(0)), address(weEth_), OrderSide.Buy, limits[0]
|
||||
);
|
||||
|
||||
weEth_.approve(address(adapter), type(uint256).max);
|
||||
@@ -160,7 +160,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
/// work(balance is shares)
|
||||
deal(address(adapter), type(uint128).max);
|
||||
adapter.swap(
|
||||
pair, IERC20(address(0)), weEth_, OrderSide.Buy, specifiedAmount
|
||||
pair, address(address(0)), address(weEth_), OrderSide.Buy, specifiedAmount
|
||||
);
|
||||
|
||||
weEth_.approve(address(adapter), specifiedAmount);
|
||||
@@ -175,7 +175,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 realAmountWeEth_ = weEth_balance - weEth_bal_before;
|
||||
|
||||
Trade memory trade =
|
||||
adapter.swap(pair, weEth_, eEth_, side, realAmountWeEth_);
|
||||
adapter.swap(pair, address(weEth_), address(eEth_), side, realAmountWeEth_);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
if (side == OrderSide.Buy) {
|
||||
@@ -216,10 +216,10 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
{
|
||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||
|
||||
IERC20 eth_ = IERC20(address(0));
|
||||
address eth_ = address(0);
|
||||
IERC20 eEth_ = IERC20(address(eEth));
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, eth_, eEth_);
|
||||
uint256[] memory limits = adapter.getLimits(pair, eth_, address(eEth_));
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 10);
|
||||
@@ -235,7 +235,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 eEth_balance = eEth_.balanceOf(address(this));
|
||||
|
||||
Trade memory trade =
|
||||
adapter.swap(pair, eth_, eEth_, side, specifiedAmount);
|
||||
adapter.swap(pair, eth_, address(eEth_), side, specifiedAmount);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
if (side == OrderSide.Buy) {
|
||||
@@ -271,10 +271,10 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
{
|
||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||
|
||||
IERC20 eth_ = IERC20(address(0));
|
||||
address eth_ = address(0);
|
||||
IERC20 weEth_ = IERC20(address(weEth));
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(pair, eth_, weEth_);
|
||||
uint256[] memory limits = adapter.getLimits(pair, eth_, address(weEth_));
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 10);
|
||||
@@ -290,7 +290,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 weEth_balance = weEth_.balanceOf(address(this));
|
||||
|
||||
Trade memory trade =
|
||||
adapter.swap(pair, eth_, weEth_, side, specifiedAmount);
|
||||
adapter.swap(pair, eth_, address(weEth_), side, specifiedAmount);
|
||||
|
||||
if (trade.calculatedAmount > 0) {
|
||||
if (side == OrderSide.Buy) {
|
||||
@@ -350,8 +350,8 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
|
||||
trades[i] = adapter.swap(
|
||||
pair,
|
||||
IERC20(address(weEth)),
|
||||
IERC20(address(eEth)),
|
||||
address(address(weEth)),
|
||||
address(address(eEth)),
|
||||
side,
|
||||
amounts[i]
|
||||
);
|
||||
@@ -372,14 +372,14 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
public
|
||||
{
|
||||
Capability[] memory res =
|
||||
adapter.getCapabilities(pair, IERC20(t0), IERC20(t1));
|
||||
adapter.getCapabilities(pair, address(t0), address(t1));
|
||||
|
||||
assertEq(res.length, 3);
|
||||
}
|
||||
|
||||
function testGetTokensEtherfi() public {
|
||||
bytes32 pair = bytes32(0);
|
||||
IERC20[] memory tokens = adapter.getTokens(pair);
|
||||
address[] memory tokens = adapter.getTokens(pair);
|
||||
|
||||
assertEq(tokens.length, 3);
|
||||
}
|
||||
@@ -387,7 +387,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
||||
function testGetLimitsEtherfi() public {
|
||||
bytes32 pair = bytes32(0);
|
||||
uint256[] memory limits = adapter.getLimits(
|
||||
pair, IERC20(address(eEth)), IERC20(address(weEth))
|
||||
pair, address(eEth), address(weEth)
|
||||
);
|
||||
|
||||
assertEq(limits.length, 2);
|
||||
|
||||
Reference in New Issue
Block a user