Skip to content

bokkypoobah/umswap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

umswap - "Like WETH, but for ERC-721s"

Umswaps are subsets of ERC-721 NFT collections pooled into ERC-20 tokens.

Umswaps are created by UmswapFactory.

UI being built at https://bokkypoobah.github.io/umswap/.




History



Umswap Functions

Umswap Read Functions

allowance(tokenOwner, spender)

Standard ERC-20 function.

function allowance(address tokenOwner, address spender) override external view returns (uint remaining)

balanceOf(tokenOwner)

Standard ERC-20 function.

function balanceOf(address tokenOwner) override external view returns (uint balance)

decimals()

Standard ERC-20 function. Set to 18 decimals.

function decimals() override external view returns (uint8)

getInfo()

function getInfo() public view returns (address _creator, string memory __symbol, string memory __name, uint[] memory _tokenIds, uint _swappedIn, uint _swappedOut, uint __totalSupply)

isValidTokenId(tokenId)

function isValidTokenId(uint _tokenId) public view returns (bool)

name()

Standard ERC-20 function.

function name() override external view returns (string memory)

symbol()

Standard ERC-20 function.

function symbol() override external view returns (string memory)

totalSupply()

Standard ERC-20 function.

function totalSupply() override external view returns (uint)

Umswap Write Functions

approve(spender, tokens)

Standard ERC-20 function.

function approve(address spender, uint tokens) override external returns (bool success)

receive()

Receive any tips in ETH.

receive() external payable

swap(inTokenIds, outTokenIds, integrator)

function swap(uint[] calldata _inTokenIds, uint[] calldata _outTokenIds, address integrator) public payable reentrancyGuard

transfer(to, tokens)

Standard ERC-20 function.

function transfer(address to, uint tokens) override external returns (bool success)

transferFrom(from, to, tokens)

Standard ERC-20 function.

function transferFrom(address from, address to, uint tokens) override external returns (bool success)


UmswapFactory Functions

UmswapFactory Read Functions

isValidName

Is name valid? Name cannot start or end with spaces, or contain repeating spaces. Name must be between 1 and 48 characters in length. Valid characters are 0-9, A-Z, a-z, space, +, -, : .

function isValidName(string memory str) public pure returns (bool)

getUmswapsLength

function getUmswapsLength() public view returns (uint _length)

getUmswaps

function getUmswaps(uint[] memory indices) public view returns (
    Umswap[] memory _umswaps,
    address[] memory _creators,
    string[] memory _symbols,
    string[] memory _names,
    uint[][] memory _tokenIds,
    uint[] memory _swappedIns,
    uint[] memory _swappedOuts,
    uint[] memory _totalSupplies
)

owner

Owner of UmswapFactory

address public owner

umswaps

Array of child Umswap addresses

Umswap[] public umswaps

UmswapFactory Write Functions

newUmswap

function newUmswap(IERC721Partial _collection, string calldata _name, uint[] calldata _tokenIds, address integrator)

receive

receive() external payable

transferOwnership

function transferOwnership(address _newOwner) public onlyOwner

withdraw

function withdraw(address token, uint tokens, uint tokenId) public onlyOwner

Testing

See test/00_test_0.js for the testing scripts and testIt.out for the results.


UmswapFactory

  • Owned
    • Can only initialise once AlreadyInitialised()
    • Transfer ownership
      • Valid ownership transfer
      • Invalid ownership transfer NotOwner()
  • TipHandler
    • Zero tips
    • Non-zero tips
      • integrator set to address(0)
      • integrator set to address(this)
      • integrator set to EOA/contract address/contract that rejects ETH payment
  • CloneFactory
    • Check
  • UmswapFactory
    • newUmswap(...)
      • Collection set to EOA NotERC721()
      • Collection set to non ERC-721 contract NotERC721()
      • Invalid name InvalidName()
      • TokenIds not sorted ascending TokenIdsMustBeSortedWithNoDuplicates()
      • Duplicate set DuplicateSet()
    • Receive ETH transfers
    • Reject ERC-721 safeTransferFrom(msg.sender, UmswapFactory, tokenId) transfers
    • Withdraw
      • ETH
      • ERC-20
      • ERC-721
      • Not owner NotOwner()

Umswap

  • [ ]
    • [ ]

Notes

npm install --save-dev hardhat OpenZeppelin v4.7.0 npm install --save-dev @openzeppelin/test-helpers npm install --save-dev @nomicfoundation/hardhat-toolbox

Releases

No releases published

Packages

No packages published