/zen

Zen is a token trading protocol for transferring NFTs P2P.

Primary LanguageSolidityGNU Affero General Public License v3.0AGPL-3.0

zen ⛩️ • tests lints

Introducing Zen, Zen is the garden inclusive and zero fee swapping mechanism for the Azuki community. Have peace of mind whilst finding your forever bean. Built by the community, for the community. IKZ!

Website

Feel free to test the dApp by minting a test NFT on Rinkeby: https://rinkeby.etherscan.io/address/0x5ac976a37067eec00c1de7dc5b9b6d37d93e56c2

Refer to https://github.com/zkSoju/zen-next for the dApp.

Features

  • Swap mechanic
    • Base swap functionality (ERC721A)
    • Ownership validation
    • $BOBU support
  • Testing suite
    • Isolated createSwap and acceptSwap tests
    • Composite ERC721 + ERC1155 tests
    • Isolated ERC721 Tests
    • Isolated ERC1155 Tests (shouldn't be able to swap?)
    • Test invalid swaps and cancelations
    • Test ownership and swap validation

Gas Usage

At gas prices (61 gwei/gas) at $2,524/ETH conversion rate the following are prices on average:

  • Create a swap: $16.91 (109841 gas)
  • Accept a swap: $8.60 (55908 gas)
  • Cancel a swap: $1.75 (11391 gas)

snapshot

Blueprint

lib
├─ ds-test — https://github.com/dapphub/ds-test
├─ forge-std — https://github.com/brockelmore/forge-std
├─ solmate — https://github.com/Rari-Capital/solmate
├─ clones-with-immutable-args — https://github.com/wighawag/clones-with-immutable-args
src
├─ tests
│  └─ Zen.t — "Zen Tests"
└─ Zen"Core Swapping Mechanism"

Development

Setup

First set the ETH_RPC_URL with an Alchemy or Infura RPC URK in .env as shown in .env.example. Test suite will be ran on a fork of the mainnet.

make
# OR #
make setup

Building

make build

Testing

make test

Deployment & Verification

Inside the scripts/ directory are a few preconfigured scripts that can be used to deploy and verify contracts.

Scripts take inputs from the cli, using silent mode to hide any sensitive information.

NOTE: These scripts are required to be executable meaning they must be made executable by running chmod +x ./scripts/*.

NOTE: For local deployment, make sure to run yarn or npm install before running the deploy_local.sh script. Otherwise, hardhat will error due to missing dependencies.

NOTE: these scripts will prompt you for the contract name and deployed addresses (when verifying). Also, they use the -i flag on forge to ask for your private key for deployment. This uses silent mode which keeps your private key from being printed to the console (and visible in logs).


First time with Forge/Foundry?

See the official Foundry installation instructions.

Don't have rust installed? Run

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then, install the foundry toolchain installer (foundryup) with:

curl -L https://foundry.paradigm.xyz | bash

Now that you've installed the foundryup binary, anytime you need to get the latest forge or cast binaries, you can run foundryup.

So, simply execute:

foundryup

🎉 Foundry is installed! 🎉


Writing Tests with Foundry

With Foundry, tests are written in Solidity! 🥳

Create a test file for your contract in the src/tests/ directory.

For example, src/Greeter.sol has its test file defined in ./src/tests/Greeter.t.sol.

To learn more about writing tests in Solidity for Foundry and Dapptools, reference Rari Capital's solmate repository largely created by @transmissions11.

Configure Foundry

Using foundry.toml, Foundry is easily configurable.

For a full list of configuration options, see the Foundry configuration documentation.

License

AGPL-3.0-only

Acknowledgements