Skip to content

Commit

Permalink
Adjust code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobrunoah committed Jul 1, 2024
1 parent 9ddbd95 commit d4eb26e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/pool-hooks/contracts/DirectionalFeeHookExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ contract DirectionalFeeHookExample is BaseHooks {
);
}

// @notice Directional fee hook, for simplicity, assumes that the pool math is linear and that final balances of
// token in and out are changed proportionally, with a rate 1:1. Then, the charged fee percentage is
// (distance between balances of token in and token out) / (total liquidity of both tokens).
// For example, if token in has a final balance of 100, and token out has a final balance of 40, the
// charged swap fee percentage is (100 - 40) / (140) = 60/140 = 42.85%
/** @notice This example assumes that the pool math is linear and that final balances of token in and out are
* changed proportionally. This approximation is just to illustrate this hook in a simple manner, but is
* also reasonable since stable pools behave linearly near the equilibrium. Also, this example requires
* the rates to be 1:1, which is common among assets that are pegged around the same value, such as USD.
* The charged fee percentage is:
*
* (distance between balances of token in and token out) / (total liquidity of both tokens)
*
* For example, if token in has a final balance of 100, and token out has a final balance of 40, the
* charged swap fee percentage is (100 - 40) / (140) = 60/140 = 42.85%
*/
function _calculatedExpectedSwapFeePercentage(
uint256[] memory poolBalances,
uint256 swapAmount,
Expand Down

0 comments on commit d4eb26e

Please sign in to comment.