0

I understand that the Pair contract will use TWPA to ensure price average, this _update function is called when Mint, Burn, Swap. In case the average period does not have the above transactions, the Sync function will be called to update the average price. So where is Sync called from? Is it called from the Service backend outside the contract?

@inheritdoc IPool function sync() external nonReentrant {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), rese rve0, reserve1); }

1 Answer 1

1

The sync() function does not have any limitation on who can call it. Anyone can call it from a service server or even manually from their address, as often as they want.

The Uniswap V2 whitepaper describes the intended use of the function:

To protect against bespoke token implementations that can update the pair contract’s balance, and to more gracefully handle tokens whose total supply can be greater than 2^112, Uniswap v2 has two bail-out functions: sync() and skim().

sync() functions as a recovery mechanism in the case that a token asynchronously deflates the balance of a pair. In this case, trades will receive sub-optimal rates, and if no liquidity provider is willing to rectify the situation, the pair is stuck. sync() exists to set the reserves of the contract to the current balances, providing a somewhat graceful recovery from this situation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.