1

I am currently working on a Uniswap V2 fork. However I am somewhat confused as to how to set the fees to my liking. I need help finding the contract and function in the contract to set the fees to my liking. Any help would be appreciated.

0

1 Answer 1

2

The fee of 3/1000 is hard coded.

uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3)); 
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: 

balance0 and balance1 are the balances/reserves after the swap finished, reserve0 and reserve1 before that (swap is done first and then maybe reverted, when the requirements are not met)

It is required that you do not reduce the product of the reserves (otherwise you could steal liquidity from the pool)

balance0 * balance1 >= reserve0 * reserve1

where balance will be the new reserve after the swap. The facors of 1000 do not change this inequality.

balance0 * 1000 * balance1 * 1000 >= reserver0 * reserve1 * 1000**2

As you can see, the balance0Adjusted is not quite balance0 * 1000. By reducing that, balance0 must be higher to forefill the requirement (same for 1), hence you have to put in more for the same output. That's where the fees of 3/1000 are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.