Skip to content

Commit

Permalink
fix: address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpers authored and asoong committed May 27, 2021
1 parent 2296f6e commit 5c6fcfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions contracts/protocol/integration/exchange/ZeroExApiAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ contract ZeroExApiAdapter {
(inputToken, outputToken) = _decodeTokensFromUniswapV3EncodedPath(encodedPath);
} else if (selector == 0x3598d8ab) {
// sellEthForTokenToUniswapV3()
// TODO(kimpers): is this correct?
inputTokenAmount = 0;
inputTokenAmount = _sourceQuantity;
bytes memory encodedPath;
(encodedPath, minOutputTokenAmount, recipient) =
abi.decode(_data[4:], (bytes, uint256, address));
supportsRecipient = true;
(inputToken, outputToken) = _decodeTokensFromUniswapV3EncodedPath(encodedPath);
inputToken = ETH_ADDRESS;
(, outputToken) = _decodeTokensFromUniswapV3EncodedPath(encodedPath);
} else {
revert("Unsupported 0xAPI function selector");
}
Expand Down Expand Up @@ -208,9 +208,8 @@ contract ZeroExApiAdapter {
address outputToken
)
{
require(encodedPath.length > 20, "UniswapV3 token path too short");
require(encodedPath.length >= UNISWAP_V3_SINGLE_HOP_PATH_SIZE, "UniswapV3 token path too short");
uint256 numHops = (encodedPath.length - 20)/UNISWAP_V3_SINGLE_HOP_OFFSET_SIZE;
require(numHops > 0, "UniswapV3 token path too short");

if (numHops == 1) {
(inputToken, outputToken) = _decodePoolInfoFromPathWithOffset(encodedPath, 0);
Expand Down
3 changes: 1 addition & 2 deletions test/protocol/integration/exchange/zeroExApiAdapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,7 @@ describe("ZeroExApiAdapter", () => {
data,
);
expect(target).to.eq(zeroExMock.address);
// TODO(kimpers): is value 0 correct here?
expect(value).to.deep.eq(ZERO);
expect(value).to.deep.eq(sourceQuantity);
expect(_data).to.deep.eq(data);
});
}
Expand Down

0 comments on commit 5c6fcfc

Please sign in to comment.