forked from paradigmxyz/artemis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SudoOpenseaArb.sol
52 lines (36 loc) · 1.72 KB
/
SudoOpenseaArb.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Seaport} from "../src/protocols/Seaport/contracts/Seaport.sol";
import {LSSVMPairETH} from "../src/protocols/LSSVMPairFactory/contracts/LSSVMPairETH.sol";
import {BasicOrderParameters} from "../src/protocols/Seaport/contracts/lib/ConsiderationStructs.sol";
import {IERC721} from "../src/protocols/LSSVMPairFactory/contracts/imports/IERC721.sol";
import {Owned} from "solmate/auth/Owned.sol";
contract SudoOpenseaArb is Owned {
error NoProfit();
constructor() Owned(msg.sender) {}
Seaport constant seaport = Seaport(0x00000000000001ad428e4906aE43D8F9852d0dD6);
function executeArb(BasicOrderParameters calldata basicOrder, uint256 paymentValue, address payable sudo_pool) public {
uint256 initialBalance = address(this).balance;
// buy NFT on opensea
seaport.fulfillBasicOrder{value: paymentValue}(basicOrder);
// set approval for sudo pool
IERC721(basicOrder.offerToken).approve(sudo_pool, basicOrder.offerIdentifier);
// sell into pool
uint256[] memory nftIds = new uint256[](1);
nftIds[0] = basicOrder.offerIdentifier;
LSSVMPairETH(sudo_pool).swapNFTsForToken(
nftIds,
0, // we don't need to set min output since we revert later on if execution isn't profitable
payable(address(this)),
false,
address(0)
);
// revert if we didn't make a profit
if (address(this).balance <= initialBalance) revert NoProfit();
}
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
fallback() external payable {}
receive() external payable {}
}