infrastructure-upgrade/lib/v3-core/contracts/test/SwapMathTest.sol
T-Hax 735546619e
init
Signed-off-by: T-Hax <>
2023-04-08 18:46:18 +00:00

38 lines
974 B
Solidity

// 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();
}
}