Wisdom Oparaocha On Deploying SudoSwap using Hardhat — A Complete Overview Advanced/Devs notes

BLOCK6
BLOCK6
Published in
3 min readAug 13, 2022

I’ve recently been playing with the recent SudoSwap NFT Market AMM. Here’s a few developers notes to help you get started.

Deploying SudoSwap using Hardhat

The first issue we faced with SudoSwap, was deployment, since our environment is mainly Hardhat, we converted the SudoSwap deployment script to a Hardhat Eqv, which you can copy and use

# Creating Pairs

#1 Dev Notes

Pairs can be created by calling any of the following 2 functions:

  1. createPairETH
  2. createPairERC20 (shown above)

When any of these 2 functions are called, a “Pair” address is returned, which inherits one of the following:

# Pair Variants

A. LSSVMPairEnumerableERC20 which inherits all public or external functions from LSSVMPairEnumerable, LSSVMPairERC20

B. LSSVMPairMissingEnumerableERC20 which inherits all public and external functions from LSSVMPairMissingEnumerable, LSSVMPairERC20

C. LSSVMPairEnumerableETH which inherits all public and external functions from LSSVMPairEnumerable, LSSVMPairETH

D. LSSVMPairMissingEnumerableETH which inherits all public and external functions from LSSVMPairMissingEnumerable, LSSVMPairETH

Note that all variants expose pairVariant() function, and inherit LSSVMPairETH as a base

If there’s a need to validate whether a Pair is a variant, you can make a call to the isPair(address potentialPair, PairVariant variant) function, and passing the variant address and 0 to 3 to check whether a given address belongs to a pair .

# NewPair

When either an ETH pair or ERC-20 Pair is created, an NewPair event is emitted, from LSSVMPairFactory — you should be listening to this event, along with all of the listed events listed in PairFactor and the Router.

It's important to not only listen to Pairs, but to routinely validate their holdings, per/collection, on the backend. This is because when a User wants to make a Swap, from the FrontEnd, we would need to pass the Pair Addresses which contains the collections/assets the user wants to pass through.

# Ropsten Deployment

I’ve deployed SudoSwap on Ropsten for you to use:

# Side Notes made during review

https://etherscan.io/txs?a=0x75d4bdbf6593ed463e9625694272a0ff9a6d346f&p=6

Configurations start from block: 14650105 end: 14652182 block

A pool, or liquidity pool, is a smart contract that allows you to instantly swap between two assets. Within SudoSwap, each time a user creates a pair, it creates an LP, which is broadcast via an event.

A Backend application is required to keep track of events and new pairs and their NFT/Token contents. An Array of pairs would need to be supplied to the router to make a swap.

In this case, it’d be great to have services which optimise swaps to find best routes

When you sell an NFT on sudoswap, it is immediately sold into a bonding curve for the best price possible. This means that you receive the proceeds of the sale right away.

When you list an NFT on sudoswap, you can set whatever price you want, but you have to wait until someone buys it from you.

Tests for createPairERC20

https://ropsten.etherscan.io/tx/0x65b434cbd51e2275c1e44bf7585f829225fddb56ecea83ae3df241d82d035680

It created a new pool for this “createPairERC20” call and moved the tokens to the pool address of: 0x4737d1ae1ed89d06fa1f42db4b59e789f6f52d17

Note: We used “0” for all the configurations, so it mostly only established a new pool.

https://ropsten.etherscan.io/tx/0x2327afcffe30eae6eecaa7993e36914b2ef7c644550c6f3c400e3d1a091e5ad6

It did exactly the same thing as above. This time, we transferred NFTs 1,2 Ids that were approved from the collection, to the new pool. This also set the initial price at 20000000000000000–0.02 Tokens per/NFT which would increment by a delta of 0.

Pool Address: 0x5a1182c61c596b7a6b8790a72f72fc6ebe27b38e

# Repo

Hope it helped,

Wisdom Oparaocha

Contents distributed by Learn.Block6.tech

👉 Discord — Live Talks

👉 Twitter — Latest articles

👉 LinkTr.ee

--

--

BLOCK6
BLOCK6

BLOCK6 — CHANGING THE WORLD WITH BLOCKCHAIN → https://linktr.ee/block6https://block6.tech — Wisdom Oparaocha