atomicDEX-API icon indicating copy to clipboard operation
atomicDEX-API copied to clipboard

ERC721/ERC1155 support adding for EVM protocols

Open tonymorony opened this issue 4 years ago • 8 comments

NFT tokens adding should increase protocol usage possibilities. Let's research/brainstorm on these assets wallet/trading features integration @artemii235

tonymorony avatar Apr 12 '21 06:04 tonymorony

Thanks for creating the issue!

I had a bit of an overview of various NFT marketplaces on ETH and BSC recently and they are completely different from exchanges :slightly_smiling_face: Our current UI with order books won't match it for sure, so I propose to consider starting with some UI mockups first taking existing products into account. This will also help us realize what endpoints we need from API.

The marketplaces I had a brief overview of: https://opensea.io/ https://www.bakeryswap.org/#/exchange/new-artworks https://juggerworld.com/

artemii235 avatar Apr 12 '21 06:04 artemii235

Related info EIP-721 EIP-1155 https://www.quicknode.com/guides/knowledge-base/look-up-all-nfts-for-a-given-address-on-ethereum-mainnet - works only on Ethereum mainnet.

artemii235 avatar Nov 15 '22 10:11 artemii235

So, after some research, I have discovered the following problems of implementing the support in a way described in the private doc:

  1. To get ownership data, we need to know all NFT smart contract addresses in advance. They should be specified in the coins file and/or it should be possible for the user to add them manually.
  2. Even if we know NFT addresses, it might be impossible to get token IDs of specific owner. It's possible with optional enumeration extension. And some contracts do not implement it. Even with this extension, scanning process can be time and traffic extensive.
  3. As mentioned in the call, we can try using custom https://www.quicknode.com/docs/ethereum/qn_fetchNFTs RPC. But this way, we will become strongly dependent on QuickNode. Also, this RPC is not supported on Binance Smart chain.
  4. We can also try https://docs.etherscan.io/api-endpoints/tokens#get-address-erc721-token-holding and maybe other explorer APIs, yet we will depend on 3rd party too.
  5. Getting NFTs transfers history is also non-trivial - we will have to scan events of each smart contract, which is also time and data consuming.

So, for this task, we will likely need our own service/API for smooth experience. I guess depending on 3rd parties is undesirable, and doing everything client-side might be very suboptimal.

@tonymorony @ca333

artemii235 avatar Nov 15 '22 12:11 artemii235

To me it looks like we'll need to use 3rd party service for this feature anyway: running cloud/dedicated server archive Ethereum node is estimating for almost 100k$/year (crazy hardware is needed atm, especially storage) + we'll need to maintain it and so on

https://moralis.io/nft-api/ - this solution seems to has widest blockchains coverage (covering all the blockchains we might need) and stating Metamask/1inch and so on (and just closed 40M funding so seems to be pretty alive for now). I do propose to base our implementation on this API

Also here is a (just as backup plan): https://www.nftport.xyz/data-api this solution covers NFT on Ethereum, Polygon and Solana

It's the best way for sure to build stuff agnostic way without relying on 3rd parties but it looks like it might be suboptimal for this particular feature

tonymorony avatar Nov 21 '22 15:11 tonymorony

todo for NFT Wallet support:

  • [x] impl withdraw_nft
    • [x] impl erc1155 withdrawing
    • [x] impl erc721 withdrawing
  • [x] cover all EVM based protocols that we already support
  • [x] combine withdraw erc721 and erc1155 functions
  • [x] moralis request tests
  • [x] impl db support
    • [x] sqlite support
    • [x] filters for get_nft_transfers
    • [x] indexedDB support
    • [x] database tests
  • [x] add proxy service support, so user wont need to use their own api-key
  • [x] protect_from_spam mod

Future refactors:

Future enhancements:

  • add gui-auth
  • allow user to use their own moralis api-key (feature for those who dont want to create their own proxy)
  • NFT activation using NFT conf in coin config file

laruh avatar Feb 15 '23 08:02 laruh

Bizdev research pointed on the fact that people also use NFTs on Polygon, it shouldn't change this feature design I guess since it's just EVM copypaste blockchains. Moralis NFT API support Polygon NFTs and also supports Avalanche and Fantom which are EVM clones as well so we can just support them all (I guess) as just NFT on EVM chain (so updated issue name accrodingly)

tonymorony avatar Feb 22 '23 14:02 tonymorony

RnD for swaps:

  • one of the optional ways of solving problem of swaps and ordermatching is to add enable nft methods/add nft config/use enable_eth_with_tokens comment
  • it worth adding url for proxy in enable method/nft config comment

laruh avatar May 05 '23 06:05 laruh

Necessary enhancements and todos for NFT SWAP part

  • [ ] Proxy-auth layer https://github.com/KomodoPlatform/komodo-defi-framework/pull/2100 https://github.com/KomodoPlatform/komodo-defi-proxy/pull/22
  • [ ] NFT activation uses NFT conf from coin config file https://github.com/KomodoPlatform/komodo-defi-framework/pull/2129
  • [x] Choose Etomic Swap implementation approach https://github.com/KomodoPlatform/etomic-swap/pull/7#issuecomment-2028600225
  • [ ] have the NFT swap state machine implementation as generic as it can be https://github.com/KomodoPlatform/komodo-defi-framework/pull/2084#discussion_r1552185720

laruh avatar Apr 05 '24 11:04 laruh