feat: Implemented getLimits
This commit is contained in:
@@ -60,7 +60,9 @@ contract EtherfiAdapter is ISwapAdapter {
|
|||||||
address buyTokenAddress = address(_buyToken);
|
address buyTokenAddress = address(_buyToken);
|
||||||
|
|
||||||
for (uint256 i = 0; i < _specifiedAmounts.length; i++) {
|
for (uint256 i = 0; i < _specifiedAmounts.length; i++) {
|
||||||
_prices[i] = getPriceAt(sellTokenAddress, buyTokenAddress, _specifiedAmounts[i]);
|
_prices[i] = getPriceAt(
|
||||||
|
sellTokenAddress, buyTokenAddress, _specifiedAmounts[i]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,34 +78,39 @@ contract EtherfiAdapter is ISwapAdapter {
|
|||||||
checkInputTokens(address(sellToken), address(buyToken))
|
checkInputTokens(address(sellToken), address(buyToken))
|
||||||
returns (Trade memory trade)
|
returns (Trade memory trade)
|
||||||
{
|
{
|
||||||
// if (specifiedAmount == 0) {
|
if (specifiedAmount == 0) {
|
||||||
// return trade;
|
return trade;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// address sellTokenAddress = address(sellToken);
|
address sellTokenAddress = address(sellToken);
|
||||||
// address buyTokenAddress = address(buyToken);
|
address buyTokenAddress = address(buyToken);
|
||||||
// uint256 gasBefore = gasleft();
|
uint256 gasBefore = gasleft();
|
||||||
// if (sellTokenAddress == address(0)) {
|
if (sellTokenAddress == address(0)) {
|
||||||
// if (buyTokenAddress == address(eEth)) {
|
if (buyTokenAddress == address(eEth)) {
|
||||||
// trade.calculatedAmount = swapEthForEeth(specifiedAmount,
|
trade.calculatedAmount = swapEthForEeth(specifiedAmount, side);
|
||||||
// side);
|
} else {
|
||||||
// } else {
|
trade.calculatedAmount = swapEthForWeEth(specifiedAmount, side);
|
||||||
// trade.calculatedAmount = swapEthForWeEth(specifiedAmount,
|
}
|
||||||
// side);
|
} else {
|
||||||
// }
|
if (sellTokenAddress == address(eEth)) {
|
||||||
// } else {
|
trade.calculatedAmount = swapEthForWeEth(specifiedAmount, side);
|
||||||
// if (sellTokenAddress == address(eEth)) {
|
} else {
|
||||||
// trade.calculatedAmount = swapEthForWeEth(specifiedAmount,
|
trade.calculatedAmount = swapWeEthForEeth(specifiedAmount, side);
|
||||||
// side);
|
}
|
||||||
// } else {
|
}
|
||||||
// trade.calculatedAmount = swapWeEthForEeth(specifiedAmount,
|
trade.gasUsed = gasBefore - gasleft();
|
||||||
// side);
|
if (side == OrderSide.Sell) {
|
||||||
// }
|
trade.price = getPriceAt(
|
||||||
// }
|
sellTokenAddress, buyTokenAddress, specifiedAmount
|
||||||
// trade.gasUsed = gasBefore - gasleft();
|
);
|
||||||
// // trade.price = getPriceAt();
|
} else {
|
||||||
|
trade.price = getPriceAt(
|
||||||
|
sellTokenAddress, buyTokenAddress, trade.calculatedAmount
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @inheritdoc ISwapAdapter
|
||||||
function getLimits(bytes32, IERC20 sellToken, IERC20 buyToken)
|
function getLimits(bytes32, IERC20 sellToken, IERC20 buyToken)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
@@ -115,16 +122,10 @@ contract EtherfiAdapter is ISwapAdapter {
|
|||||||
address buyTokenAddress = address(buyToken);
|
address buyTokenAddress = address(buyToken);
|
||||||
limits = new uint256[](2);
|
limits = new uint256[](2);
|
||||||
|
|
||||||
if (sellTokenAddress == address(0)) {
|
/// @dev only limit on Etherfi is applied on deposits(eth->eETH), and is type(uint128).max
|
||||||
if (buyTokenAddress == address(eEth)) {} else { // ETH-weEth
|
/// but we use the same amount for the others to underestimate
|
||||||
}
|
limits[0] = type(uint128).max;
|
||||||
} else if (sellTokenAddress == address(weEth)) {
|
limits[1] = limits[0];
|
||||||
if (buyTokenAddress == address(0)) {} else { // weEth-ETH
|
|
||||||
}
|
|
||||||
} else if (sellTokenAddress == address(eEth)) {
|
|
||||||
if (buyTokenAddress == address(0)) {} else { // eEth-weEth
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCapabilities(bytes32 poolId, IERC20 sellToken, IERC20 buyToken)
|
function getCapabilities(bytes32 poolId, IERC20 sellToken, IERC20 buyToken)
|
||||||
|
|||||||
Reference in New Issue
Block a user