Created
July 18, 2023 16:43
-
-
Save giovannidisiena/965baba8f5e76807704be7f474fe33a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: AGPL-3.0 | |
| pragma solidity ^0.8.0; | |
| contract LSSVMRouter { | |
| function swapNFTsForSpecificNFTsThroughETH( | |
| NFTsForSpecificNFTsTrade calldata trade, | |
| uint256 minOutput, | |
| address payable ethRecipient, | |
| address nftRecipient, | |
| uint256 deadline | |
| ) external payable checkDeadline(deadline) returns (uint256 outputAmount) { | |
| // Swap NFTs for ETH | |
| // minOutput of swap set to 0 since we're doing an aggregate slippage check | |
| outputAmount = _swapNFTsForToken(trade.nftToTokenTrades, 0, payable(address(this))); | |
| // Add extra value to buy NFTs | |
| outputAmount += msg.value; | |
| // Swap ETH for specific NFTs | |
| // cost <= inputValue = outputAmount - minOutput, so outputAmount' = (outputAmount - minOutput - cost) + minOutput >= minOutput | |
| outputAmount = _swapETHForSpecificNFTs( | |
| trade.tokenToNFTTrades, outputAmount - minOutput, ethRecipient, nftRecipient | |
| ) + minOutput; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment