Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I pointed the quoter at non canonical AMMs that implement uniswap v2/v3 broadly, I found an instance of minor non-compliance that makes it impossible to get a quote.
Specifically I found that pancake swap returns protocol fees as
uint32
rather thanuint8
inslot0
.The quoter doesn't actually use any of the non-compliant data, and as calldata abi encodes all primitives as 32 byte values regardless of the
uint
bit size, there should be no danger in acceptinguint256
values for anything that is discarded by the quoter anyway.The issue is that even if the quoter never uses the data, it is decoded and checked for overflows by Solidity according to the interface anyway.
Perhaps this could be considered a bug in Solidity, that ignored data is a revert condition, or perhaps this is desired behaviour upstream as it implies the interfaces differ (which they do in this case, but in a harmless way I believe).
This PR implements a loose version of the
slot0
call that acceptsuint256
for all values that the quoter ignores anyway.This is a much bigger change than the minimum required to support pancake swap, which would just be a move from
uint8
touint32
on the protocol fee. The reason I set all these touint256
is that I didn't want to overfit for pancake swap specifically. In the scheme of things I don't really care about pancake swap, I'm more interested in being able to use the quoter in as many situations as possible.