KomodoPlatform / komodo-defi-framework

This is the official Komodo DeFi Framework repository
https://komodoplatform.com/en/docs/komodo-defi-framework/
105 stars 94 forks source link

ERC721/ERC1155 support adding for EVM protocols #900

Open tonymorony opened 3 years ago

tonymorony commented 3 years ago

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

artemii235 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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

tonymorony commented 1 year ago

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

laruh commented 1 year ago

todo for NFT Wallet support:

Future refactors:

Future enhancements:

tonymorony commented 1 year ago

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)

laruh commented 1 year ago

RnD for swaps:

laruh commented 7 months ago

Necessary enhancements and todos for NFT SWAP part