fix: Fixed Fractions
This commit is contained in:
Submodule evm/lib/forge-std updated: f73c73d201...155d547c44
@@ -2,6 +2,7 @@
|
|||||||
pragma solidity ^0.8.13;
|
pragma solidity ^0.8.13;
|
||||||
|
|
||||||
import {IERC20, ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
import {IERC20, ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||||
|
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
|
||||||
|
|
||||||
/// @dev Integral submitted deadline of 3600 seconds (1 hour) to Paraswap, but it is not strictly necessary to be this long
|
/// @dev Integral submitted deadline of 3600 seconds (1 hour) to Paraswap, but it is not strictly necessary to be this long
|
||||||
/// as the contract allows less durations, we use 1000 seconds (15 minutes) as a deadline
|
/// as the contract allows less durations, we use 1000 seconds (15 minutes) as a deadline
|
||||||
@@ -33,7 +34,10 @@ contract IntegralSwapAdapter is ISwapAdapter {
|
|||||||
uint256 price_ = relayer.getPriceByTokenAddresses(address(_sellToken), address(_buyToken));
|
uint256 price_ = relayer.getPriceByTokenAddresses(address(_sellToken), address(_buyToken));
|
||||||
|
|
||||||
for (uint256 i = 0; i < _specifiedAmounts.length; i++) {
|
for (uint256 i = 0; i < _specifiedAmounts.length; i++) {
|
||||||
_prices[i] = Fraction(price_, 1);
|
_prices[i] = Fraction(
|
||||||
|
relayer.getPriceByTokenAddresses(address(_sellToken), address(_buyToken)) * 10**(ERC20(address(_sellToken)).decimals()) / 10**18,
|
||||||
|
10**(ERC20(address(_buyToken)).decimals())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,12 +62,10 @@ contract IntegralSwapAdapter is ISwapAdapter {
|
|||||||
buy(sellToken, buyToken, specifiedAmount);
|
buy(sellToken, buyToken, specifiedAmount);
|
||||||
}
|
}
|
||||||
trade.gasUsed = gasBefore - gasleft();
|
trade.gasUsed = gasBefore - gasleft();
|
||||||
/**
|
trade.price = Fraction(
|
||||||
* @dev once we get reply from propeller about return values in price() function and in every Fraction
|
relayer.getPriceByTokenAddresses(address(sellToken), address(buyToken)) * 10**(ERC20(address(sellToken)).decimals()) / 10**18,
|
||||||
* Fraction[0] = relayer.getPriceByTokenAddresses(address(sellToken), address(buyToken)) * 10^(IERC20(sellToken).decimals) / 10^18
|
10**(ERC20(address(buyToken)).decimals())
|
||||||
* Fraction[1] = 10^(IERC20(buyToken).decimals)
|
);
|
||||||
*/
|
|
||||||
trade.price = Fraction(relayer.getPriceByTokenAddresses(address(sellToken), address(buyToken)), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @inheritdoc ISwapAdapter
|
/// @inheritdoc ISwapAdapter
|
||||||
@@ -197,11 +199,9 @@ contract IntegralSwapAdapter is ISwapAdapter {
|
|||||||
uint256 limitMax1
|
uint256 limitMax1
|
||||||
) = relayer.getPoolState(address(sellToken), address(buyToken));
|
) = relayer.getPoolState(address(sellToken), address(buyToken));
|
||||||
|
|
||||||
uint256[] memory limits_ = new uint256[](2);
|
limits = new uint256[](2);
|
||||||
limits_[0] = limitMax0;
|
limits[0] = limitMax0;
|
||||||
limits_[1] = limitMax1;
|
limits[1] = limitMax1;
|
||||||
|
|
||||||
return limits_;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes {
|
|||||||
uint256 limitMax1
|
uint256 limitMax1
|
||||||
) = relayer.getPoolState(address(sellToken), address(buyToken));
|
) = relayer.getPoolState(address(sellToken), address(buyToken));
|
||||||
|
|
||||||
uint256[] memory limits_ = new uint256[](2);
|
limits = new uint256[](2);
|
||||||
limits_[0] = limitMin0;
|
limits[0] = limitMin0;
|
||||||
limits_[1] = limitMin1;
|
limits[1] = limitMin1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function testPriceFuzzIntegral(uint256 amount0, uint256 amount1) public {
|
function testPriceFuzzIntegral(uint256 amount0, uint256 amount1) public {
|
||||||
|
|||||||
Reference in New Issue
Block a user