chore: forge fmt
This commit is contained in:
@@ -72,8 +72,7 @@ contract AngleAdapter is ISwapAdapter {
|
|||||||
uint8 decimals = side == OrderSide.Sell
|
uint8 decimals = side == OrderSide.Sell
|
||||||
? IERC20Metadata(sellToken).decimals()
|
? IERC20Metadata(sellToken).decimals()
|
||||||
: IERC20Metadata(buyToken).decimals();
|
: IERC20Metadata(buyToken).decimals();
|
||||||
trade.price =
|
trade.price = getPriceAt(sellToken, buyToken, side, decimals);
|
||||||
getPriceAt(sellToken, buyToken, side, decimals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @inheritdoc ISwapAdapter
|
/// @inheritdoc ISwapAdapter
|
||||||
@@ -103,8 +102,7 @@ contract AngleAdapter is ISwapAdapter {
|
|||||||
} else {
|
} else {
|
||||||
limits[0] = IERC20(sellToken).balanceOf(transmuterAddress);
|
limits[0] = IERC20(sellToken).balanceOf(transmuterAddress);
|
||||||
}
|
}
|
||||||
limits[1] =
|
limits[1] = transmuter.quoteIn(limits[0], sellToken, buyToken);
|
||||||
transmuter.quoteIn(limits[0], sellToken, buyToken);
|
|
||||||
limits[1] = limits[1] / RESERVE_LIMIT_FACTOR;
|
limits[1] = limits[1] / RESERVE_LIMIT_FACTOR;
|
||||||
limits[0] = limits[0] / RESERVE_LIMIT_FACTOR;
|
limits[0] = limits[0] / RESERVE_LIMIT_FACTOR;
|
||||||
} else {
|
} else {
|
||||||
@@ -117,8 +115,7 @@ contract AngleAdapter is ISwapAdapter {
|
|||||||
} else {
|
} else {
|
||||||
limits[1] = IERC20(buyToken).balanceOf(transmuterAddress);
|
limits[1] = IERC20(buyToken).balanceOf(transmuterAddress);
|
||||||
}
|
}
|
||||||
limits[0] =
|
limits[0] = transmuter.quoteIn(limits[1], buyToken, sellToken);
|
||||||
transmuter.quoteIn(limits[1], buyToken, sellToken);
|
|
||||||
limits[1] = limits[1] / RESERVE_LIMIT_FACTOR;
|
limits[1] = limits[1] / RESERVE_LIMIT_FACTOR;
|
||||||
limits[0] = limits[0] / RESERVE_LIMIT_FACTOR;
|
limits[0] = limits[0] / RESERVE_LIMIT_FACTOR;
|
||||||
}
|
}
|
||||||
@@ -212,18 +209,14 @@ contract AngleAdapter is ISwapAdapter {
|
|||||||
internal
|
internal
|
||||||
returns (uint256 calculatedAmount)
|
returns (uint256 calculatedAmount)
|
||||||
{
|
{
|
||||||
calculatedAmount =
|
calculatedAmount = transmuter.quoteOut(amountOut, sellToken, buyToken);
|
||||||
transmuter.quoteOut(amountOut, sellToken, buyToken);
|
|
||||||
|
|
||||||
IERC20(sellToken).safeTransferFrom(msg.sender, address(this), calculatedAmount);
|
IERC20(sellToken).safeTransferFrom(
|
||||||
|
msg.sender, address(this), calculatedAmount
|
||||||
|
);
|
||||||
IERC20(sellToken).approve(address(transmuter), calculatedAmount);
|
IERC20(sellToken).approve(address(transmuter), calculatedAmount);
|
||||||
transmuter.swapExactOutput(
|
transmuter.swapExactOutput(
|
||||||
amountOut,
|
amountOut, type(uint256).max, sellToken, buyToken, msg.sender, 0
|
||||||
type(uint256).max,
|
|
||||||
sellToken,
|
|
||||||
buyToken,
|
|
||||||
msg.sender,
|
|
||||||
0
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,10 +150,7 @@ contract EtherfiAdapter is ISwapAdapter {
|
|||||||
|
|
||||||
/// @dev Limits are underestimated to 90% of totalSupply as both weEth
|
/// @dev Limits are underestimated to 90% of totalSupply as both weEth
|
||||||
/// and eEth have no limits but revert in some cases
|
/// and eEth have no limits but revert in some cases
|
||||||
if (
|
if (sellToken == address(weEth) || buyToken == address(weEth)) {
|
||||||
sellToken == address(weEth)
|
|
||||||
|| buyToken == address(weEth)
|
|
||||||
) {
|
|
||||||
limits[0] = IERC20(address(weEth)).totalSupply() * 90 / 100;
|
limits[0] = IERC20(address(weEth)).totalSupply() * 90 / 100;
|
||||||
} else {
|
} else {
|
||||||
limits[0] = IERC20(address(eEth)).totalSupply() * 90 / 100;
|
limits[0] = IERC20(address(eEth)).totalSupply() * 90 / 100;
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||||
|
|
||||||
bytes32 pair = bytes32(0);
|
bytes32 pair = bytes32(0);
|
||||||
uint256[] memory limits = adapter.getLimits(pair, address(EURC), address(agEUR));
|
uint256[] memory limits =
|
||||||
|
adapter.getLimits(pair, address(EURC), address(agEUR));
|
||||||
|
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 0);
|
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 0);
|
||||||
@@ -53,8 +54,9 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
uint256 eurc_balance = EURC.balanceOf(address(this));
|
uint256 eurc_balance = EURC.balanceOf(address(this));
|
||||||
uint256 agEUR_balance = agEUR.balanceOf(address(this));
|
uint256 agEUR_balance = agEUR.balanceOf(address(this));
|
||||||
|
|
||||||
Trade memory trade =
|
Trade memory trade = adapter.swap(
|
||||||
adapter.swap(pair, address(EURC), address(agEUR), side, specifiedAmount);
|
pair, address(EURC), address(agEUR), side, specifiedAmount
|
||||||
|
);
|
||||||
|
|
||||||
if (trade.calculatedAmount > 0) {
|
if (trade.calculatedAmount > 0) {
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
@@ -85,7 +87,8 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||||
|
|
||||||
bytes32 pair = bytes32(0);
|
bytes32 pair = bytes32(0);
|
||||||
uint256[] memory limits = adapter.getLimits(pair, address(agEUR), address(EURC));
|
uint256[] memory limits =
|
||||||
|
adapter.getLimits(pair, address(agEUR), address(EURC));
|
||||||
|
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 0);
|
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 0);
|
||||||
@@ -102,8 +105,9 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
uint256 eurc_balance = EURC.balanceOf(address(this));
|
uint256 eurc_balance = EURC.balanceOf(address(this));
|
||||||
uint256 agEUR_balance = agEUR.balanceOf(address(this));
|
uint256 agEUR_balance = agEUR.balanceOf(address(this));
|
||||||
|
|
||||||
Trade memory trade =
|
Trade memory trade = adapter.swap(
|
||||||
adapter.swap(pair, address(agEUR), address(EURC), side, specifiedAmount);
|
pair, address(agEUR), address(EURC), side, specifiedAmount
|
||||||
|
);
|
||||||
|
|
||||||
if (trade.calculatedAmount > 0) {
|
if (trade.calculatedAmount > 0) {
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
@@ -154,7 +158,9 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
deal(address(agEUR), address(this), type(uint256).max);
|
deal(address(agEUR), address(this), type(uint256).max);
|
||||||
agEUR.approve(address(adapter), type(uint256).max);
|
agEUR.approve(address(adapter), type(uint256).max);
|
||||||
}
|
}
|
||||||
trades[i] = adapter.swap(pair, address(agEUR), address(EURC), side, amounts[i]);
|
trades[i] = adapter.swap(
|
||||||
|
pair, address(agEUR), address(EURC), side, amounts[i]
|
||||||
|
);
|
||||||
vm.revertTo(beforeSwap);
|
vm.revertTo(beforeSwap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +179,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
function testGetCapabilitiesAngle(bytes32 pair, address t0, address t1)
|
function testGetCapabilitiesAngle(bytes32 pair, address t0, address t1)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
Capability[] memory res =
|
Capability[] memory res = adapter.getCapabilities(pair, t0, t1);
|
||||||
adapter.getCapabilities(pair, t0, t1);
|
|
||||||
|
|
||||||
assertEq(res.length, 2);
|
assertEq(res.length, 2);
|
||||||
}
|
}
|
||||||
@@ -187,7 +192,8 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
|
|
||||||
function testGetLimitsAngle() public {
|
function testGetLimitsAngle() public {
|
||||||
bytes32 pair = bytes32(0);
|
bytes32 pair = bytes32(0);
|
||||||
uint256[] memory limits = adapter.getLimits(pair, address(agEUR), address(EURC));
|
uint256[] memory limits =
|
||||||
|
adapter.getLimits(pair, address(agEUR), address(EURC));
|
||||||
|
|
||||||
assertEq(limits.length, 2);
|
assertEq(limits.length, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
IERC20 eEth_ = IERC20(address(eEth));
|
IERC20 eEth_ = IERC20(address(eEth));
|
||||||
IERC20 weEth_ = IERC20(address(weEth));
|
IERC20 weEth_ = IERC20(address(weEth));
|
||||||
bytes32 pair = bytes32(0);
|
bytes32 pair = bytes32(0);
|
||||||
uint256[] memory limits = adapter.getLimits(pair, address(eEth_), address(weEth_));
|
uint256[] memory limits =
|
||||||
|
adapter.getLimits(pair, address(eEth_), address(weEth_));
|
||||||
|
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 100);
|
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 100);
|
||||||
@@ -67,7 +68,11 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
/// work(balance is shares)
|
/// work(balance is shares)
|
||||||
deal(address(adapter), type(uint256).max);
|
deal(address(adapter), type(uint256).max);
|
||||||
adapter.swap(
|
adapter.swap(
|
||||||
pair, address(address(0)), address(eEth_), OrderSide.Buy, limits[0]
|
pair,
|
||||||
|
address(address(0)),
|
||||||
|
address(eEth_),
|
||||||
|
OrderSide.Buy,
|
||||||
|
limits[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
eEth_.approve(address(adapter), type(uint256).max);
|
eEth_.approve(address(adapter), type(uint256).max);
|
||||||
@@ -78,7 +83,11 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
/// work(balance is shares)
|
/// work(balance is shares)
|
||||||
deal(address(adapter), type(uint128).max);
|
deal(address(adapter), type(uint128).max);
|
||||||
adapter.swap(
|
adapter.swap(
|
||||||
pair, address(address(0)), address(eEth_), OrderSide.Buy, specifiedAmount
|
pair,
|
||||||
|
address(address(0)),
|
||||||
|
address(eEth_),
|
||||||
|
OrderSide.Buy,
|
||||||
|
specifiedAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
eEth_.approve(address(adapter), specifiedAmount);
|
eEth_.approve(address(adapter), specifiedAmount);
|
||||||
@@ -87,8 +96,9 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
uint256 eEth_balance = eEth_.balanceOf(address(this));
|
uint256 eEth_balance = eEth_.balanceOf(address(this));
|
||||||
uint256 weEth_balance = weEth_.balanceOf(address(this));
|
uint256 weEth_balance = weEth_.balanceOf(address(this));
|
||||||
|
|
||||||
Trade memory trade =
|
Trade memory trade = adapter.swap(
|
||||||
adapter.swap(pair, address(eEth_), address(weEth_), side, specifiedAmount);
|
pair, address(eEth_), address(weEth_), side, specifiedAmount
|
||||||
|
);
|
||||||
|
|
||||||
if (trade.calculatedAmount > 0) {
|
if (trade.calculatedAmount > 0) {
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
@@ -140,7 +150,8 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
IERC20 weEth_ = IERC20(address(weEth));
|
IERC20 weEth_ = IERC20(address(weEth));
|
||||||
uint256 weEth_bal_before = weEth_.balanceOf(address(this));
|
uint256 weEth_bal_before = weEth_.balanceOf(address(this));
|
||||||
bytes32 pair = bytes32(0);
|
bytes32 pair = bytes32(0);
|
||||||
uint256[] memory limits = adapter.getLimits(pair, address(weEth_), address(eEth_));
|
uint256[] memory limits =
|
||||||
|
adapter.getLimits(pair, address(weEth_), address(eEth_));
|
||||||
|
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 100);
|
vm.assume(specifiedAmount < limits[1] && specifiedAmount > 100);
|
||||||
@@ -149,7 +160,11 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
/// work(balance is shares)
|
/// work(balance is shares)
|
||||||
deal(address(adapter), type(uint256).max);
|
deal(address(adapter), type(uint256).max);
|
||||||
adapter.swap(
|
adapter.swap(
|
||||||
pair, address(address(0)), address(weEth_), OrderSide.Buy, limits[0]
|
pair,
|
||||||
|
address(address(0)),
|
||||||
|
address(weEth_),
|
||||||
|
OrderSide.Buy,
|
||||||
|
limits[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
weEth_.approve(address(adapter), type(uint256).max);
|
weEth_.approve(address(adapter), type(uint256).max);
|
||||||
@@ -160,7 +175,11 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
/// work(balance is shares)
|
/// work(balance is shares)
|
||||||
deal(address(adapter), type(uint128).max);
|
deal(address(adapter), type(uint128).max);
|
||||||
adapter.swap(
|
adapter.swap(
|
||||||
pair, address(address(0)), address(weEth_), OrderSide.Buy, specifiedAmount
|
pair,
|
||||||
|
address(address(0)),
|
||||||
|
address(weEth_),
|
||||||
|
OrderSide.Buy,
|
||||||
|
specifiedAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
weEth_.approve(address(adapter), specifiedAmount);
|
weEth_.approve(address(adapter), specifiedAmount);
|
||||||
@@ -174,8 +193,9 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
/// therefore we use weEth_balance - weEth_bal_before as specifiedAmount
|
/// therefore we use weEth_balance - weEth_bal_before as specifiedAmount
|
||||||
uint256 realAmountWeEth_ = weEth_balance - weEth_bal_before;
|
uint256 realAmountWeEth_ = weEth_balance - weEth_bal_before;
|
||||||
|
|
||||||
Trade memory trade =
|
Trade memory trade = adapter.swap(
|
||||||
adapter.swap(pair, address(weEth_), address(eEth_), side, realAmountWeEth_);
|
pair, address(weEth_), address(eEth_), side, realAmountWeEth_
|
||||||
|
);
|
||||||
|
|
||||||
if (trade.calculatedAmount > 0) {
|
if (trade.calculatedAmount > 0) {
|
||||||
if (side == OrderSide.Buy) {
|
if (side == OrderSide.Buy) {
|
||||||
@@ -386,9 +406,8 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
|
|
||||||
function testGetLimitsEtherfi() public {
|
function testGetLimitsEtherfi() public {
|
||||||
bytes32 pair = bytes32(0);
|
bytes32 pair = bytes32(0);
|
||||||
uint256[] memory limits = adapter.getLimits(
|
uint256[] memory limits =
|
||||||
pair, address(eEth), address(weEth)
|
adapter.getLimits(pair, address(eEth), address(weEth));
|
||||||
);
|
|
||||||
|
|
||||||
assertEq(limits.length, 2);
|
assertEq(limits.length, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user