-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7d4fc1
Showing
69 changed files
with
24,011 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain-types | ||
yarn-error.log | ||
|
||
#Hardhat files | ||
artifacts/ | ||
hh-cache/ | ||
|
||
|
||
.DS_Store | ||
|
||
# VScode | ||
.vscode | ||
__pycache__ | ||
|
||
.openzeppelin | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
artifacts | ||
cache | ||
coverage* | ||
gasReporterOutput.json |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Shoyu | ||
|
||
Shoyu | ||
|
||
## Install | ||
|
||
To install dependencies and compile contracts: | ||
|
||
```bash | ||
git clone https://github.com/ProjectOpenSea/seaport && cd seaport | ||
yarn install | ||
yarn build | ||
``` | ||
|
||
## Usage | ||
|
||
To run hardhat tests written in javascript: | ||
|
||
```bash | ||
yarn test | ||
yarn coverage | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
skipFiles: [ | ||
"seaport/Conduit.sol", | ||
"seaport/ConduitController.sol", | ||
"seaport/ImmutableCreate2FactoryInterface.sol", | ||
"seaport/Seaport.sol", | ||
"test/EIP1271Wallet.sol", | ||
"test/ExcessReturnDataRecipient.sol", | ||
"test/ERC1155BatchRecipient.sol", | ||
"test/Reenterer.sol", | ||
"test/TestERC1155.sol", | ||
"test/TestERC20.sol", | ||
"test/TestERC721.sol", | ||
"test/TestZone.sol", | ||
"test/TestWETH.sol" | ||
], | ||
configureYulOptimizer: true, | ||
solcOptimizerDetails: { | ||
yul: true, | ||
yulDetails: { | ||
stackAllocation: true, | ||
}, | ||
}, | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"extends": "solhint:all", | ||
"rules": { | ||
"compiler-version": ["error", ">=0.8.7"], | ||
"func-visibility": ["warn", { "ignoreConstructors": true }], | ||
"no-empty-blocks": "off", | ||
"no-inline-assembly": "off", | ||
"avoid-low-level-calls": "off", | ||
"not-rely-on-time": "off", | ||
"var-name-mixedcase": "off", | ||
"func-name-mixedcase": "off", | ||
"max-line-length": ["warn", 80], | ||
"function-max-lines": "off", | ||
"code-complexity": ["warn", 15] | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules/ | ||
|
||
contracts/test/ | ||
|
||
test/ | ||
lib/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ChainId } from "@sushiswap/core-sdk"; | ||
|
||
export const CONDUIT_CONTROLLER_ADDRESS: { [chainId: number]: string } = { | ||
[ChainId.ETHEREUM]: "0x00000000006ce100a8b5ed8edf18ceef9e500697", | ||
[ChainId.RINKEBY]: "0x00000000006ce100a8b5ed8edf18ceef9e500697", | ||
[ChainId.GÖRLI]: "0x00000000006ce100a8b5ed8edf18ceef9e500697", | ||
}; | ||
|
||
export const SEAPORT_ADDRESS: { [chainId: number]: string } = { | ||
[ChainId.ETHEREUM]: "0x00000000006c3852cbef3e08e8df289169ede581", | ||
[ChainId.RINKEBY]: "0x00000000006c3852cbef3e08e8df289169ede581", | ||
[ChainId.GÖRLI]: "0x00000000006c3852cbEf3e08E8dF289169EdE581", | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
module.exports = Object.freeze({ | ||
KEYLESS_CREATE2_DEPLOYER_ADDRESS: | ||
"0x4c8D290a1B368ac4728d83a9e8321fC3af2b39b1", | ||
KEYLESS_CREATE2_DEPLOYMENT_TRANSACTION: | ||
"0xf87e8085174876e800830186a08080ad601f80600e600039806000f350fe600036" + | ||
"81823780368234f58015156014578182fd5b80825250506014600cf31ba022222222" + | ||
"22222222222222222222222222222222222222222222222222222222a02222222222" + | ||
"222222222222222222222222222222222222222222222222222222", | ||
KEYLESS_CREATE2_ADDRESS: "0x7A0D94F55792C434d74a40883C6ed8545E406D12", | ||
KEYLESS_CREATE2_RUNTIME_CODE: | ||
"0x60003681823780368234f58015156014578182fd5b80825250506014600cf3", | ||
KEYLESS_CREATE2_RUNTIME_HASH: | ||
"0x60003681823780368234f58015156014578182fd5b80825250506014600cf3", | ||
INEFFICIENT_IMMUTABLE_CREATE2_FACTORY_ADDRESS: | ||
"0xcfA3A7637547094fF06246817a35B8333C315196", | ||
IMMUTABLE_CREATE2_FACTORY_ADDRESS: | ||
"0x0000000000FFe8B47B3e2130213B802212439497", | ||
IMMUTABLE_CREATE2_FACTORY_SALT: | ||
"0x0000000000000000000000000000000000000000f4b0218f13a6440a6f020000", | ||
IMMUTABLE_CREATE2_FACTORY_CREATION_CODE: | ||
"0x608060405234801561001057600080fd5b50610833806100206000396000f3fe60" + | ||
"806040526004361061003f5760003560e01c806308508b8f1461004457806364e030" + | ||
"871461009857806385cf97ab14610138578063a49a7c90146101bc575b600080fd5b" + | ||
"34801561005057600080fd5b506100846004803603602081101561006757600080fd" + | ||
"5b503573ffffffffffffffffffffffffffffffffffffffff166101ec565b60408051" + | ||
"9115158252519081900360200190f35b61010f600480360360408110156100ae5760" + | ||
"0080fd5b813591908101906040810160208201356401000000008111156100d05760" + | ||
"0080fd5b8201836020820111156100e257600080fd5b803590602001918460018302" + | ||
"8401116401000000008311171561010457600080fd5b509092509050610217565b60" + | ||
"40805173ffffffffffffffffffffffffffffffffffffffff90921682525190819003" + | ||
"60200190f35b34801561014457600080fd5b5061010f600480360360408110156101" + | ||
"5b57600080fd5b813591908101906040810160208201356401000000008111156101" + | ||
"7d57600080fd5b82018360208201111561018f57600080fd5b803590602001918460" + | ||
"018302840111640100000000831117156101b157600080fd5b509092509050610592" + | ||
"565b3480156101c857600080fd5b5061010f600480360360408110156101df576000" + | ||
"80fd5b508035906020013561069e565b73ffffffffffffffffffffffffffffffffff" + | ||
"ffffff1660009081526020819052604090205460ff1690565b600083606081901c33" + | ||
"148061024c57507fffffffffffffffffffffffffffffffffffffffff000000000000" + | ||
"0000000000008116155b6102a1576040517f08c379a0000000000000000000000000" + | ||
"00000000000000000000000000000000815260040180806020018281038252604581" + | ||
"52602001806107746045913960600191505060405180910390fd5b60608484808060" + | ||
"1f016020809104026020016040519081016040528093929190818152602001838380" + | ||
"8284376000920182905250604051855195965090943094508b935086925060209182" + | ||
"01918291908401908083835b6020831061033557805182527fffffffffffffffffff" + | ||
"ffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101" + | ||
"6102f8565b51815160209384036101000a7fffffffffffffffffffffffffffffffff" + | ||
"ffffffffffffffffffffffffffffffff018019909216911617905260408051929094" + | ||
"018281037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + | ||
"ffffe00183528085528251928201929092207fff0000000000000000000000000000" + | ||
"00000000000000000000000000000000008383015260609890981b7fffffffffffff" + | ||
"ffffffffffffffffffffffffffff0000000000000000000000001660218301526035" + | ||
"82019690965260558082019790975282518082039097018752607501825250845194" + | ||
"84019490942073ffffffffffffffffffffffffffffffffffffffff81166000908152" + | ||
"938490529390922054929350505060ff16156104a7576040517f08c379a000000000" + | ||
"00000000000000000000000000000000000000000000000081526004018080602001" + | ||
"8281038252603f815260200180610735603f913960400191505060405180910390fd" + | ||
"5b81602001825188818334f5955050508073ffffffffffffffffffffffffffffffff" + | ||
"ffffffff168473ffffffffffffffffffffffffffffffffffffffff161461053a5760" + | ||
"40517f08c379a0000000000000000000000000000000000000000000000000000000" + | ||
"0081526004018080602001828103825260468152602001806107b960469139606001" + | ||
"91505060405180910390fd5b50505073ffffffffffffffffffffffffffffffffffff" + | ||
"ffff8116600090815260208190526040902080547fffffffffffffffffffffffffff" + | ||
"ffffffffffffffffffffffffffffffffffff001660011790559392505050565b6000" + | ||
"308484846040516020018083838082843760408051919093018181037fffffffffff" + | ||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffe001825280845281" + | ||
"516020928301207fff00000000000000000000000000000000000000000000000000" + | ||
"0000000000008383015260609990991b7fffffffffffffffffffffffffffffffffff" + | ||
"ffffff00000000000000000000000016602182015260358101979097526055808801" + | ||
"9890985282518088039098018852607590960182525085519585019590952073ffff" + | ||
"ffffffffffffffffffffffffffffffffffff81166000908152948590529490932054" + | ||
"939450505060ff909116159050610697575060005b9392505050565b604080517fff" + | ||
"00000000000000000000000000000000000000000000000000000000000000602080" + | ||
"8301919091523060601b602183015260358201859052605580830185905283518084" + | ||
"0390910181526075909201835281519181019190912073ffffffffffffffffffffff" + | ||
"ffffffffffffffffff81166000908152918290529190205460ff161561072e575060" + | ||
"005b9291505056fe496e76616c696420636f6e7472616374206372656174696f6e20" + | ||
"2d20636f6e74726163742068617320616c7265616479206265656e206465706c6f79" + | ||
"65642e496e76616c69642073616c74202d206669727374203230206279746573206f" + | ||
"66207468652073616c74206d757374206d617463682063616c6c696e672061646472" + | ||
"6573732e4661696c656420746f206465706c6f7920636f6e7472616374207573696e" + | ||
"672070726f76696465642073616c7420616e6420696e697469616c697a6174696f6e" + | ||
"20636f64652ea265627a7a723058202bdc55310d97c4088f18acf04253db593f0914" + | ||
"059f0c781a9df3624dcef0d1cf64736f6c634300050a0032", | ||
IMMUTABLE_CREATE2_FACTORY_RUNTIME_HASH: | ||
"0x767db8f19b71e367540fa372e8e81e4dcb7ca8feede0ae58a0c0bd08b7320dee", | ||
CONDUIT_CONTROLLER_CREATION_HASH: | ||
"0x78dcd34ae05f701d578e1495cd9f254e60e28883bd1e921917c12141daa2d45a", | ||
CONDUIT_CONTROLLER_CREATION_SALT: | ||
"0x00000000000000000000000000000000000000003b7dcb354e842802b5060000", | ||
CONDUIT_CONTROLLER_ADDRESS: "0x00000000006cE100a8b5eD8eDf18ceeF9e500697", | ||
MARKETPLACE_CONTRACT_CREATION_HASH: | ||
"0x5161158f3bd737116360d9468eb4cf10436e07754e823d48f9f081e9f17cff43", | ||
MARKETPLACE_CONTRACT_CREATION_SALT: | ||
"0x00000000000000000000000000000000000000000db1a5942723530096000000", | ||
MARKETPLACE_CONTRACT_ADDRESS: "0x00000000006CEE72100D161c57ADA5Bb2be1CA79", | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.13; | ||
|
||
import "seaport/contracts/conduit/Conduit.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.13; | ||
|
||
import "seaport/contracts/conduit/ConduitController.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.13; | ||
|
||
import "seaport/contracts/interfaces/ImmutableCreate2FactoryInterface.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.13; | ||
|
||
import "seaport/contracts/Seaport.sol"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.13; | ||
|
||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; | ||
import "@rari-capital/solmate/src/tokens/ERC20.sol"; | ||
import "@rari-capital/solmate/src/tokens/ERC721.sol"; | ||
import "@rari-capital/solmate/src/tokens/ERC1155.sol"; | ||
import "./interfaces/IShoyu.sol"; | ||
import "./lib/AdapterRegistry.sol"; | ||
import "../sushiswap/IBentoBoxMinimal.sol"; | ||
|
||
contract Shoyu is Initializable, UUPSUpgradeable, OwnableUpgradeable, PausableUpgradeable { | ||
AdapterRegistry public adapterRegistry; | ||
|
||
function initialize(address _adapterRegistery, address _bentobox) initializer public { | ||
adapterRegistry = AdapterRegistry(_adapterRegistery); | ||
IBentoBoxMinimal(_bentobox).registerProtocol(); | ||
|
||
__Ownable_init(); | ||
} | ||
|
||
function cook( | ||
uint8[] calldata adapterIds, | ||
uint256[] calldata values, | ||
bytes[] calldata datas | ||
) external payable whenNotPaused { | ||
uint256 length = adapterIds.length; | ||
for (uint256 i; i < length; ++i) { | ||
( | ||
address adapterAddress, | ||
bool isLibrary, | ||
bool isActive | ||
) = adapterRegistry.adapters(adapterIds[i]); | ||
|
||
require(isActive, "cook: inactive adapter"); | ||
|
||
(bool success, ) = isLibrary ? adapterAddress.delegatecall(datas[i]) | ||
: adapterAddress.call{value: values[i]}(datas[i]); | ||
|
||
if (!success) { | ||
assembly { | ||
returndatacopy(0, 0, returndatasize()) | ||
revert(0, returndatasize()) | ||
} | ||
} | ||
} | ||
|
||
_refundExcessETH(); | ||
} | ||
|
||
function _transferETH(address to, uint256 amount) internal { | ||
assembly { | ||
let success := call(gas(), to, amount, 0, 0, 0, 0) | ||
if eq(success, 0) { revert(0, 0) } | ||
} | ||
} | ||
|
||
function _refundExcessETH() internal { | ||
uint256 balance = address(this).balance; | ||
if (balance > 0) { | ||
_transferETH(msg.sender, balance); | ||
} | ||
} | ||
|
||
function approveERC20( | ||
address token, | ||
address operator, | ||
uint256 amount | ||
) external onlyOwner { | ||
ERC20(token).approve(operator, amount); | ||
} | ||
|
||
function retrieveETH(address to, uint256 amount) onlyOwner external { | ||
_transferETH(to, amount); | ||
} | ||
|
||
function retrieveERC20(address token, address to, uint256 amount) onlyOwner external { | ||
ERC20(token).transfer(to, amount); | ||
} | ||
|
||
function retrieveERC721( | ||
address token, | ||
uint256[] calldata tokenIds, | ||
address to | ||
) onlyOwner external { | ||
uint256 length = tokenIds.length; | ||
for (uint256 i; i < length; ++i) { | ||
ERC721(token).safeTransferFrom(address(this), to, tokenIds[i]); | ||
} | ||
} | ||
|
||
function retrieveERC1155( | ||
address token, | ||
uint256[] calldata tokenIds, | ||
uint256[] calldata amounts, | ||
address to | ||
) onlyOwner external { | ||
ERC1155(token).safeBatchTransferFrom(address(this), to, tokenIds, amounts, ""); | ||
} | ||
|
||
/// @dev Fallback for just receiving ether. | ||
receive() external payable {} | ||
|
||
/// @dev Allows this contract to receive ERC1155 tokens | ||
function onERC1155Received( | ||
address, | ||
address, | ||
uint256, | ||
uint256, | ||
bytes calldata | ||
) public virtual returns (bytes4) { | ||
return this.onERC1155Received.selector; | ||
} | ||
|
||
function onERC1155BatchReceived( | ||
address, | ||
address, | ||
uint256[] calldata, | ||
uint256[] calldata, | ||
bytes calldata | ||
) public virtual returns (bytes4) { | ||
return this.onERC1155BatchReceived.selector; | ||
} | ||
|
||
/// @dev Required by UUPSUpgradeable | ||
function _authorizeUpgrade(address) internal override onlyOwner {} | ||
} |
Oops, something went wrong.