Skip to content

Commit

Permalink
Merge pull request #4 from ronin-chain/feature/remove-nft-commands
Browse files Browse the repository at this point in the history
feat: remove all NFT-related commands
  • Loading branch information
thaixuandang authored Aug 26, 2024
2 parents 04a360b + e81cd14 commit d06273a
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 699 deletions.
25 changes: 3 additions & 22 deletions src/aggregate-router/AggregateRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ pragma solidity ^0.8.17;

// Command implementations
import { Dispatcher } from "./base/Dispatcher.sol";
import { RewardsCollector } from "./base/RewardsCollector.sol";
import { RouterParameters } from "./base/RouterImmutables.sol";
import { PaymentsImmutables, PaymentsParameters } from "./modules/PaymentsImmutables.sol";
import { NFTImmutables, NFTParameters } from "./modules/NFTImmutables.sol";
import { KatanaImmutables, KatanaParameters } from "./modules/katana/KatanaImmutables.sol";
import { Commands } from "./libraries/Commands.sol";
import { IAggregateRouter } from "./interfaces/IAggregateRouter.sol";

contract AggregateRouter is IAggregateRouter, Dispatcher, RewardsCollector {
contract AggregateRouter is IAggregateRouter, Dispatcher {
modifier checkDeadline(uint256 deadline) {
if (block.timestamp > deadline) revert TransactionDeadlinePassed();
_;
Expand All @@ -21,24 +19,7 @@ contract AggregateRouter is IAggregateRouter, Dispatcher, RewardsCollector {
KatanaImmutables(
KatanaParameters(params.v2Factory, params.v3Factory, params.pairInitCodeHash, params.poolInitCodeHash)
)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9, params.openseaConduit, params.sudoswap))
NFTImmutables(
NFTParameters(
params.seaportV1_5,
params.seaportV1_4,
params.nftxZap,
params.x2y2,
params.foundation,
params.sudoswap,
params.elementMarket,
params.nft20Zap,
params.cryptopunks,
params.looksRareV2,
params.routerRewardsDistributor,
params.looksRareRewardsDistributor,
params.looksRareToken
)
)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9))
{ }

/// @inheritdoc IAggregateRouter
Expand Down Expand Up @@ -79,6 +60,6 @@ contract AggregateRouter is IAggregateRouter, Dispatcher, RewardsCollector {
return command & Commands.FLAG_ALLOW_REVERT == 0;
}

/// @notice To receive ETH from WETH and NFT protocols
/// @notice To receive ETH from WETH
receive() external payable { }
}
32 changes: 0 additions & 32 deletions src/aggregate-router/base/Callbacks.sol

This file was deleted.

525 changes: 159 additions & 366 deletions src/aggregate-router/base/Dispatcher.sol

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions src/aggregate-router/base/RewardsCollector.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/aggregate-router/base/RouterImmutables.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ pragma solidity ^0.8.17;
struct RouterParameters {
address permit2;
address weth9;
address seaportV1_5;
address seaportV1_4;
address openseaConduit;
address nftxZap;
address x2y2;
address foundation;
address sudoswap;
address elementMarket;
address nft20Zap;
address cryptopunks;
address looksRareV2;
address routerRewardsDistributor;
address looksRareRewardsDistributor;
address looksRareToken;
address v2Factory;
address v3Factory;
bytes32 pairInitCodeHash;
Expand Down
6 changes: 1 addition & 5 deletions src/aggregate-router/interfaces/IAggregateRouter.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;

import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IRewardsCollector } from "./IRewardsCollector.sol";

interface IAggregateRouter is IRewardsCollector, IERC721Receiver, IERC1155Receiver {
interface IAggregateRouter {
/// @notice Thrown when a required command has failed
error ExecutionFailed(uint256 commandIndex, bytes message);

Expand Down
13 changes: 0 additions & 13 deletions src/aggregate-router/interfaces/IRewardsCollector.sol

This file was deleted.

11 changes: 0 additions & 11 deletions src/aggregate-router/interfaces/external/ICryptoPunksMarket.sol

This file was deleted.

99 changes: 50 additions & 49 deletions src/aggregate-router/interfaces/external/IKatanaV2Pair.sol
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
pragma solidity >=0.5.0;

interface IKatanaV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);

function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);

function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);

function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);

function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);

function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);

function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;

function initialize(address, address) external;
}
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);

function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);

function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);

function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
external;

event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);

function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);

function mint(address to) external returns (uint256 liquidity);
function burn(address to) external returns (uint256 amount0, uint256 amount1);
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;

function initialize(address, address) external;
}
38 changes: 1 addition & 37 deletions src/aggregate-router/libraries/Commands.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,5 @@ library Commands {
uint256 constant BALANCE_CHECK_ERC20 = 0x0e;
// COMMAND_PLACEHOLDER = 0x0f;

// The commands are executed in nested if blocks to minimise gas consumption
// The following constant defines one of the boundaries where the if blocks split commands
uint256 constant SECOND_IF_BOUNDARY = 0x10;

// Command Types where 0x10<=value<0x18, executed in the third nested-if block
uint256 constant SEAPORT_V1_5 = 0x10;
uint256 constant LOOKS_RARE_V2 = 0x11;
uint256 constant NFTX = 0x12;
uint256 constant CRYPTOPUNKS = 0x13;
// 0x14;
uint256 constant OWNER_CHECK_721 = 0x15;
uint256 constant OWNER_CHECK_1155 = 0x16;
uint256 constant SWEEP_ERC721 = 0x17;

// The commands are executed in nested if blocks to minimise gas consumption
// The following constant defines one of the boundaries where the if blocks split commands
uint256 constant THIRD_IF_BOUNDARY = 0x18;

// Command Types where 0x18<=value<=0x1f, executed in the final nested-if block
uint256 constant X2Y2_721 = 0x18;
uint256 constant SUDOSWAP = 0x19;
uint256 constant NFT20 = 0x1a;
uint256 constant X2Y2_1155 = 0x1b;
uint256 constant FOUNDATION = 0x1c;
uint256 constant SWEEP_ERC1155 = 0x1d;
uint256 constant ELEMENT_MARKET = 0x1e;
// COMMAND_PLACEHOLDER = 0x1f;

// The commands are executed in nested if blocks to minimise gas consumption
// The following constant defines one of the boundaries where the if blocks split commands
uint256 constant FOURTH_IF_BOUNDARY = 0x20;

// Command Types where 0x20<=value
uint256 constant SEAPORT_V1_4 = 0x20;
uint256 constant EXECUTE_SUB_PLAN = 0x21;
uint256 constant APPROVE_ERC20 = 0x22;
// COMMAND_PLACEHOLDER for 0x23 to 0x3f (all unused)
// COMMAND_PLACEHOLDER for 0x10 to 0x3f (all unused)
}
73 changes: 0 additions & 73 deletions src/aggregate-router/modules/NFTImmutables.sol

This file was deleted.

Loading

0 comments on commit d06273a

Please sign in to comment.