Created
June 7, 2023 07:48
-
-
Save codewithgun/20b3165c9e051bb5b5ef0e8a62dd49bb to your computer and use it in GitHub Desktop.
Revisions
-
codewithgun created this gist
Jun 7, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ function test_getFeeAmount() public { // Configuration was copied from BTC.b/USDC pair bytes32 params; uint16 binStep = 10; params = params.setStaticFeeParameters(10000, 30, 600, 5000, 40000, 1000, 350000); // Set volatility accumulator to the max params = params.setVolatilityAccumulator(350000); // 5900000000000000 => 0.59% console2.log("Total fee %s", totalFee); uint128 totalFee = params.getTotalFee(binStep); uint128 inAmount = 1234567; uint128 feeAmount = inAmount.getFeeAmount(totalFee); // feeAmount = 7328. However, Math.ceil(1234567 * 0.0059) = 7284. Extra 44 wei has been charged console.log("Fee amount %s", feeAmount); }