AirSwap Protocols

repository·develop·Indexed 42 days ago

https://github.com/airswap/airswap-protocols

A collection of smart contracts and developer tools for a peer-to-peer trading network. Version 5.0.0 provides foundational logic for atomic swaps, registry management, staking, and batching calls, including core packages such as @airswap/registry, @airswap/swap, @airswap/swap-erc20, @airswap/wrapper, @airswap/staking, @airswap/pool, and @airswap/batch-call, as well as developer utilities like @airswap/libraries and @airswap/utils.

Tokens
21.1K
Snippets
88
Records
106
Agent score
53%

What's inside AirSwap

  1. Overview of AirSwap Protocols packages

    develop
    AirSwap is a peer-to-peer trading network. This repository provides the smart contracts and developer tools required to build on the AirSwap network. The ecosystem is divided into core protocol contracts and developer utility packages.
  2. Deploy and Verify AirSwap contracts

    develop

    Each package includes scripts to deploy and verify contracts on a specific network. You must provide the --network flag to specify the target network (e.g., sepolia).

    Authentication: The account used for deployment and verification is derived from the PRIVATE_KEY environment variable defined in the .env file located in the repository root.

    yarn deploy --network sepolia
    yarn verify --network sepolia
  3. Prepare the environment for running Pool tests

    develop

    Before running tests locally within the source/pool directory, you must ensure that the required artifacts are built. To do this, run the compilation command from the airswap-protocols project root.

    1. Navigate to the airswap-protocols root directory.
    2. Execute yarn compile to build the necessary artifacts.
    yarn compile
  4. Install and manage SwapERC20 via yarn

    develop

    Use the following commands to manage the SwapERC20 package. Note that environment variables should be configured in an .env file located in the repository root.

    yarn           # Install dependencies
    yarn clean      # Delete the contract build folder
    yarn compile     # Compile all contracts to build folder
    yarn coverage    # Report test coverage
    yarn test        # Run all tests in test folder
    yarn test:ci     # Run ci tests in test folder
    yarn deploy --network <network_name> # Deploy on a network
    yarn verify --network <network_name> # Verify on a network
  5. Install and use @airswap/utils

    develop

    The @airswap/utils package provides utility functions for AirSwap developers.

    To use it in your project, install it via yarn:

    yarn add @airswap/utils

    Then, import the required functions into your TypeScript application. Common utilities include toDecimalString and toAtomicString for handling numeric conversions.

    import { toDecimalString, toAtomicString } from '@airswap/utils';
  6. Run BatchCall contract tests

    develop

    To run tests for the BatchCall contract locally, follow these steps:

    1. Build Artifacts: In the airswap-protocols project root, run yarn compile to ensure all required artifacts are built.
    2. Start Local Blockchain: In a separate shell from the root repository, start a local blockchain instance using yarn ganache.
    3. Execute Tests: Run yarn test from the root repository to execute the contract tests.
    # Step 1: Build artifacts (from root)
    yarn compile
    
    # Step 2: Start blockchain (in a new shell)
    yarn ganache
    
    # Step 3: Run tests (from root)
    yarn test
  7. Install and manage BatchCall dependencies

    develop

    Use the following commands to manage the BatchCall package within the airswap-protocols repository:

    • yarn: Install all necessary dependencies.
    • yarn clean: Remove the contract build folder.
    • yarn compile: Compile all contracts into the build folder.
    • yarn test: Execute all contract tests located in the test folder.
    yarn
    yarn clean
    yarn compile
    yarn test
  8. Install and manage @airswap/delegate-erc20 via yarn

    develop

    Use the following commands to manage the @airswap/delegate-erc20 package. Note that environment variables must be configured in an .env file located in the repository root.

    Dependency Management

    • yarn: Install dependencies.
    • yarn clean: Delete the contract build folder.

    Compilation and Testing

    • yarn compile: Compile all contracts to the build folder.
    • yarn test: Run all tests in the test folder.
    • yarn test:ci: Run CI tests in the test folder.
    • yarn coverage: Report test coverage.

    Note: Before running tests locally, you must run yarn compile in the airswap-protocols project root to build the required artifacts.

    # Install dependencies
    yarn
    
    # Compile contracts
    yarn compile
    
    # Run tests
    yarn test