Skip to content

Commit

Permalink
chore: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMasayoshi committed Jan 24, 2023
1 parent 1e95ba6 commit 6ab7132
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 14 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ Currently the `AdapterRegistry` contains 2 entries:
- Composed of multiple Adapters
- `TransferAdapter`
- Includes functions to transfer tokens from the caller's wallet or from Shoyu contract. Users can utilize Shoyu's Seaport Conduit when transferring assets from their wallet.
- `LegacySwapAdapter`
- Swaps ERC20s via Sushiswap legacy pools.
- `SushiAdapter`
- Swaps ERC20s via Sushiswap trident & legacy pools.
- `WETHAdapter`
- Wrap/unwrap native tokens.
2. `SeaportAdapter`
- Fulfills a single or multiple orders on Seaport.

Expand All @@ -21,16 +23,6 @@ Example use cases:
- Purchase one or many listed NFTs with combination of ETH & ERC20s
- Accept one or many offers on NFTs and receive any ERC20/ETH

When more marketplaces are supported, it will be possible to trade across multiple markets in a single transaction. For example,

- NFT AMM has floor price at 1.5ETH
- Seaport order has item listed for 1.0 ETH
- User could buy the item on Seaport and sell it to AMM, while taking profits in a single transaction.

## Install

To install dependencies and compile contracts:

```bash
git clone https://github.com/shoyunft/shoyu-contracts && cd shoyu-contracts
yarn install
Expand Down
6 changes: 6 additions & 0 deletions contracts/shoyu/adapters/AdapterRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ pragma solidity >=0.8.11;
import "@openzeppelin/contracts/access/Ownable.sol";
import { Adapter } from "../lib/LibShoyu.sol";

/// @title AdapterRegistry
/// @notice Registry of adapter contracts that can be invoked by the Shoyu contract. Only the
/// contract owner can update the registry.
/// @dev Any exposed function in an adapter contract should be marked as payable, even if the function
/// does not strictly require it. Since the Shoyu contract can receive ETH at any point during `cook`,
/// it is possible for `msg.value` to be greater than 0, causing a non-payable function to revert.
contract AdapterRegistry is Ownable {
Adapter[] public adapters;

Expand Down
5 changes: 5 additions & 0 deletions contracts/shoyu/adapters/Markets/SeaportAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ pragma solidity >=0.8.11;
import "@rari-capital/solmate/src/tokens/ERC721.sol";
import "seaport/contracts/interfaces/ConsiderationInterface.sol";

/// @title SeaportAdapter
/// @notice Adapter which provides all order fulfillment functions of Seaport required by this contract.
/// @dev When filling an Seaport order and the consideration items include one or more NFTs, use
/// `approveBeforeFulfill` or `approveBeforeFulfillBatch` if the Shoyu contract has not already
/// granted approval of the asset(s) to the Seaport contract.
contract SeaportAdapter {
address public immutable seaportAddress;

Expand Down
2 changes: 1 addition & 1 deletion contracts/shoyu/adapters/Transfer/BentoAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "@rari-capital/solmate/src/tokens/ERC20.sol";
import "@sushiswap/trident/contracts/interfaces/IBentoBoxMinimal.sol";

/// @title BentoAdapter
/// @notice Adapter which provides all functions of BentoBox require by this contract.
/// @notice Adapter which provides all functions of BentoBox required by this contract.
/// @dev These are generic functions, make sure, only msg.sender, address(this) and address(bentoBox)
/// are passed in the from param, or else the attacker can sifu user's funds in bentobox.
contract BentoAdapter {
Expand Down
4 changes: 4 additions & 0 deletions contracts/shoyu/adapters/Transfer/ConduitAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { ConduitInterface } from "seaport/contracts/interfaces/ConduitInterface.
import { ConduitTransfer } from "seaport/contracts/conduit/lib/ConduitStructs.sol";
import { ConduitItemType } from "seaport/contracts/conduit/lib/ConduitEnums.sol";

/// @title ConduitAdapter
/// @notice Adapter which allows transferring assets using Shoyu's Seaport Conduit to source approvals.
/// @dev These are generic functions, make sure only msg.sender or address(this) are passed in the from param,
/// or else the attacker can sifu user's funds from conduit.
contract ConduitAdapter {
// Allow for interaction with the conduit controller.
ConduitControllerInterface private immutable _CONDUIT_CONTROLLER;
Expand Down
3 changes: 3 additions & 0 deletions contracts/shoyu/adapters/Transfer/TransferAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import "@rari-capital/solmate/src/tokens/ERC1155.sol";
import "./ConduitAdapter.sol";
import { TokenSource } from "../../lib/LibShoyu.sol";

/// @title TransferAdapter
/// @notice This adapter serves two purposes - transferring remaining assets from the Shoyu contract (see `returnXXX`),
/// and transferring assets from `msg.sender` with approvals being sourced from the Shoyu contract or Shoyu's Seaport Conduit.
contract TransferAdapter is ConduitAdapter {
constructor(address _conduitController) ConduitAdapter(_conduitController) {}

Expand Down
4 changes: 4 additions & 0 deletions contracts/shoyu/adapters/Transform/SushiAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
} from "../../lib/LibSushi.sol";
import { TokenSource } from "../../lib/LibShoyu.sol";

/// @title SushiAdapter
/// @notice This adapter provides support for swapping ERC20 tokens using Trident & Legacy Sushi pools.
/// @dev The swapExactOut functions transfer funds from `msg.sender`, whereas swapExactIn transfers funds
/// from address(this).
contract SushiAdapter is TransferAdapter, BentoAdapter {
/// @dev The UniswapV2Factory address.
address private immutable factory;
Expand Down
3 changes: 3 additions & 0 deletions contracts/shoyu/adapters/Transform/TransformationAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "@sushiswap/core/contracts/uniswapv2/interfaces/IWETH.sol";
import "./SushiAdapter.sol";
import "./WETHAdapter.sol";

/// @title TransformationAdapter
/// @notice This adapter combines SushiAdapter & WETHAdapter to provide a single
/// contract from which trasfer or transformation functions can be invoked.
contract TransformationAdapter is SushiAdapter, WETHAdapter {
constructor(
address _weth,
Expand Down
3 changes: 3 additions & 0 deletions contracts/shoyu/adapters/Transform/WETHAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pragma solidity >=0.8.11;
import "@sushiswap/core/contracts/uniswapv2/interfaces/IWETH.sol";
import "@rari-capital/solmate/src/tokens/ERC20.sol";

/// @title WETHAdapter
/// @notice This adapter provides support for wrapping & unwrapping native tokens.
/// @dev ETH or WETH must already held by address(this).
contract WETHAdapter {
/// @dev The WETH address.
address private immutable WETH;
Expand Down
4 changes: 3 additions & 1 deletion contracts/shoyu/lib/LibSushi.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

// Legacy Adapted from: https://github.com/sushiswap/limit-order/blob/a901749362691acd307f2370a876a33d33cde53e/contracts/libraries/UniswapV2Library.sol
// Legacy functions adapted from: https://github.com/sushiswap/limit-order/blob/a901749362691acd307f2370a876a33d33cde53e/contracts/libraries/UniswapV2Library.sol
// Trident functions adapted from: https://github.com/sushiswap/trident/blob/89b1cb6e17b9e2ec6c3b8825a8d78b8a0ab400d5/contracts/libraries/TridentRouterLibrary.sol

import "@sushiswap/trident/contracts/interfaces/IPool.sol";
import "@sushiswap/core/contracts/uniswapv2/interfaces/IUniswapV2Pair.sol";

Expand Down

0 comments on commit 6ab7132

Please sign in to comment.