Uniswap / v3-core

🦄 🦄 🦄 Core smart contracts of Uniswap v3
https://uniswap.org
Other
4.39k stars 2.7k forks source link

explore a fully fleshed-out callback pay variant #190

Closed NoahZinsmeister closed 3 years ago

NoahZinsmeister commented 3 years ago

callback pay refers to the pattern of a) the pair checking its balance, b) the pair calling a function on an address that would have to send tokens to the pair, and then c) the pair checking its balance to make sure it received enough tokens. if we're going to introduce callback pay anywhere, it probably makes sense to introduce it everywhere

this is in opposition to callback notify, which uses the callback simply to give an execution frame to flash swappers. if we use callback notify, it should only be used in swap, and only for flash swaps (indicated by data.length > 0)

a consideration in both cases is that all transferFrom calls should be sandwiched by balance checks enforcing correctness. we get this for free in callback pay, but it has to be enforced in callback notify

both variants have downstream implications for routers/integrations, which should also be explored as part of this decision

NoahZinsmeister commented 3 years ago

this should include an MVP of a router that has the logic for a multihop trade that uses nested resolution to achieve the minimum number of transfers