AirSwap Protocols
repository·develop·Indexed 42 days ago
https://github.com/airswap/airswap-protocolsA 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.
What's inside AirSwap
- 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.
Overview of BatchCall
developThe@airswap/batch-callpackage provides the source code and tests for theBatchCallcontract. This contract functions as an aggregator for ERC20 balances and allowances, allowing multiple calls to be bundled together.Use the @airswap/staking package
developThe
@airswap/stakingpackage is part of the AirSwap peer-to-peer trading network.⚠️ Warning: This package may contain unaudited code. For production use, always refer to the Deployed Contracts documentation to ensure you are interacting with verified deployments.
Run tests and coverage for the Wrapper package
developYou can execute the test suite and generate coverage reports using the following commands. Ensure artifacts are compiled first via
yarn compilein theairswap-protocolsroot.yarn test yarn test:ci yarn coverageDeploy and Verify AirSwap contracts
developEach package includes scripts to deploy and verify contracts on a specific network. You must provide the
--networkflag to specify the target network (e.g.,sepolia).Authentication: The account used for deployment and verification is derived from the
PRIVATE_KEYenvironment variable defined in the.envfile located in the repository root.yarn deploy --network sepolia yarn verify --network sepoliaPrepare the environment for running Pool tests
developBefore running tests locally within the
source/pooldirectory, you must ensure that the required artifacts are built. To do this, run the compilation command from theairswap-protocolsproject root.- Navigate to the
airswap-protocolsroot directory. - Execute
yarn compileto build the necessary artifacts.
yarn compile- Navigate to the
Install and manage SwapERC20 via yarn
developUse the following commands to manage the SwapERC20 package. Note that environment variables should be configured in an
.envfile 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 networkInstall and use @airswap/utils
developThe
@airswap/utilspackage provides utility functions for AirSwap developers.To use it in your project, install it via yarn:
yarn add @airswap/utilsThen, import the required functions into your TypeScript application. Common utilities include
toDecimalStringandtoAtomicStringfor handling numeric conversions.import { toDecimalString, toAtomicString } from '@airswap/utils';Run BatchCall contract tests
developTo run tests for the BatchCall contract locally, follow these steps:
- Build Artifacts: In the
airswap-protocolsproject root, runyarn compileto ensure all required artifacts are built. - Start Local Blockchain: In a separate shell from the root repository, start a local blockchain instance using
yarn ganache. - Execute Tests: Run
yarn testfrom 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- Build Artifacts: In the
Run tests for SwapERC20
developTo run tests for the SwapERC20 package, you must first ensure that the required artifacts are built. Run
yarn compilein theairswap-protocolsproject root before executing tests locally.# Step 1: Build artifacts in the project root yarn compile # Step 2: Run tests in the swap-erc20 directory yarn testInstall and manage BatchCall dependencies
developUse the following commands to manage the BatchCall package within the
airswap-protocolsrepository:yarn: Install all necessary dependencies.yarn clean: Remove the contractbuildfolder.yarn compile: Compile all contracts into thebuildfolder.yarn test: Execute all contract tests located in thetestfolder.
yarn yarn clean yarn compile yarn testInstall and manage @airswap/delegate-erc20 via yarn
developUse the following commands to manage the
@airswap/delegate-erc20package. Note that environment variables must be configured in an.envfile located in the repository root.Dependency Management
yarn: Install dependencies.yarn clean: Delete the contractbuildfolder.
Compilation and Testing
yarn compile: Compile all contracts to thebuildfolder.yarn test: Run all tests in thetestfolder.yarn test:ci: Run CI tests in thetestfolder.yarn coverage: Report test coverage.
Note: Before running tests locally, you must run
yarn compilein theairswap-protocolsproject root to build the required artifacts.# Install dependencies yarn # Compile contracts yarn compile # Run tests yarn test