an opinionated, Uniswap-style AMM for a wider range of token standards (erc20s, 721s, and 1155s)
Ironically, there's been an emerging class of "fungible" nfts. These include one-of-many editions, in-game items, token-gated DAOs + events, floors of popular collections, and 1155s as a class, to name a few.
While order books allow for basic trading, liquidity is sparce and equilibrium prices are difficult to find. As the NFT space moves away from just PFPs, new trading mechanisms can be implemented to help fix these issues.
This is a first step in doing that, and provides base functionality for a
proof-of-concept AMM offering any combination of ERC20
, ERC721
, and ERC1155
pairs.
Currently, ERC721
collections, ERC1155
collections with matching ID
s, and ERC20
s are
considered "fungible". It is up to the LPer to determine if their ERC721
possesses
any additional rarity traits that might discourage this type of fungibility.
During swaps, an arbitrary batch of 721s from the collection is distributed to the user. It is worth
noting that only 1155s with IDs < 2^88 are currently supported. While potentially limiting,
this ensures that all relevant token data (address tokenAddress
, uint8 tokenItemType
, uint88 optionalId
) can be placed
in a single storage slot. Additional 1155 considerations included whether all NFTs within a collection
should be fungible, or just those with the same IDs. Ultimately, the former felt more intuitive.
A tokenItemType
can be ERC20
, ERC721
, or ERC1155
A triswapPair
can be any combination of two tokenItemType
s
While NFT LPing may be an interest to some defi hobbyists, I see a more likely future where NFT collections start natively on AMMs, removing the need for minting + order books entirely. This would create significanly more sustainable communities, where quantity and pricing are determined entirely on market demand.
Current examples have primarily been single-sided liquidity bonding curves, such as Uniswap's Unisocks, Decent's Crescendo, and Glass's Prism
-
Obviously heavily inspired by Uniswap V2
-
Some techincal decisions inspired by Seaport and Sudoswap, leading players in advancing the NFT trading space
-
Built with Foundry
This is a very preliminary first implementation, and more of a thought experiment than a finished protocol
While ERC721
to ERC721
swaps are possible, there is very little reason to use them
as currently implemented, due to minimum liquidity requirements and potential rounding issues.
Considering (?) adjusting minliqudity based off of pair type, although suspect a more formal solution
is needed
More advanced LPing and trading characteristics for smaller collections, ability to select 721s (maybe), need to be implemented
Router implementation soon