-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSwapMathTest.sol
37 lines (34 loc) · 974 Bytes
/
SwapMathTest.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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();
}
}