infrastructure-upgrade/lib/v3-core/contracts/test/SwapMathTest.sol

38 lines
974 B
Solidity
Raw Normal View History

2023-04-08 21:46:18 +03:00
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/SwapMath.sol';
contract SwapMathTest {
function computeSwapStep(
uint160 sqrtP,
uint160 sqrtPTarget,
uint128 liquidity,
int256 amountRemaining,
uint24 feePips
)
external
pure
returns (
uint160 sqrtQ,
uint256 amountIn,
uint256 amountOut,
uint256 feeAmount
)
{
return SwapMath.computeSwapStep(sqrtP, sqrtPTarget, liquidity, amountRemaining, feePips);
}
function getGasCostOfComputeSwapStep(
uint160 sqrtP,
uint160 sqrtPTarget,
uint128 liquidity,
int256 amountRemaining,
uint24 feePips
) external view returns (uint256) {
uint256 gasBefore = gasleft();
SwapMath.computeSwapStep(sqrtP, sqrtPTarget, liquidity, amountRemaining, feePips);
return gasBefore - gasleft();
}
}