Giter Site home page Giter Site logo

contracts-aggregator's People

Contributors

0xhiroshi avatar 0xjurassicpunk avatar 0xshisui avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

contracts-aggregator's Issues

0x Protocol integration

  • Is your feature request related to a problem? Please describe.
    It could be interesting in a later phase to see if the aggregator model fits well with 0xProtocol (used by Coinbase) for NFT trading.

  • Describe the solution you'd like
    Implement a proxy for 0x protocol.

  • Additional context
    It would more for assessing the viability of the Order struct model with one additional marketplace.

Seaport v1.2

As Seaport is going to roll out v1.2, it is probably time to look at what can be done and how different it is to the current implementation (v1.1). ๐Ÿ‘Œ

Readability for one-line statement

Statement (like below) are hard to read.

if (balance != 0) _executeERC20DirectTransfer(tokenTransfers[i].currency, recipient, balance);

This kind of 1-line statements make it much harder to read for things that can be state-changing. Since these don't impact the gas, I suggest rewriting them such as

if (balance != 0) {
   _executeERC20DirectTransfer(tokenTransfers[i].currency, recipient, balance);
}

The only exception can be the parts in ASM or the ones that trigger a reversion statement (so not state-changing).

Check return status

 assembly {
      if gt(selfbalance(), 1) {
          let status := call(gas(), originator, sub(selfbalance(), 1), 0, 0, 0, 0)
      }
  }

We need to check the call worked since the originator is not always the Erc20EnabledLooksRareAggregator contract.

https://github.com/LooksRare/contracts-aggregator/blob/master/contracts/LooksRareAggregator.sol#L99

Also, if we don't import it from the library, I'd like to remove the ones where the recipient is not the sender because they add to the (too) large size of the v2.

Re-entrancy tests

A scam NFT contract/recipient contract can steal user balance under the following scenarios

  1. Scam NFT collections that re-enters LooksRareAggregator.execute during transferFrom
  2. Scam recipient that re-enters LooksRareAggregator during onERC721Received

which then execute a non-atomic order that fails, and the aggregator returns the contract's ETH/ERC-20 balances to the scam contract which were originally provided by the user.


Original comment from Dingbatx:

Consider this :
1. User has 2 trades (A and B), each 1 ETH, and not atomic
2. User makes trade A and the one of the call (such as transferFrom) to the NFT contract is customized to reenter the aggregator contract's execute function.
3. Reentrancy function call makes at least 1 trade. At the end of execute, the remaining ETH and ERC20 balances (provided by the user) are refunded to the NFT contract.
4. Trade B will fail due to insufficient token/ETH balance but not revert due to the execution not being atomic.

In this case, the NFT contract that does the reentrancy can steal the balance of tokens/ETH in the aggregator contract during the time of reentrancy

The current SudoswapProxy implementation cannot handle partial fills when an NFT is no longer available

The current SudoswapProxy's partial fill can only handle the case where the pool price moves out of the user's max cost. It will revert during safeTransferFrom if the NFT the user wants to purchase is no longer available.

Sudoswap will release a V2 router and it will be able to handle this scenario by checking that the token IDs are still in the pool before order execution, so we will wait until it goes live before integrating with Sudoswap again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.