Skip to content

Commit d3dc2ba

Browse files
authored
feat: add Uniswap V3 Periphery with Hardhat CI harness (#286)
* feat: add Uniswap V3 Periphery with Hardhat CI harness Adds the polkadot-cookbook test harness for the Uniswap V3 Periphery with EVM on Polkadot Hub tutorial. The harness clones revm-hardhat-examples at pinned commit 96696ad15c3cf01b9168a71ad5114f27c34a8726, installs dependencies (resolving the local @uniswap/v3-core file reference automatically), compiles the SwapRouter and NonfungiblePositionManager contracts, runs the full 39-test Hardhat suite on the local Hardhat network, and optionally deploys via Hardhat Ignition to polkadotTestnet. * docs: add Uniswap V3 Periphery entry to polkadot-docs README table
1 parent 0151961 commit d3dc2ba

10 files changed

Lines changed: 1955 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Uniswap V3 Periphery with Hardhat
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- 'polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/**'
8+
- '!polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/README.md'
9+
pull_request:
10+
paths:
11+
- 'polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/**'
12+
- '!polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/README.md'
13+
workflow_dispatch:
14+
15+
jobs:
16+
test:
17+
if: github.repository == 'polkadot-developers/polkadot-cookbook'
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: '22'
26+
27+
- name: Cache npm dependencies (upstream uniswap-v3-periphery-hardhat)
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/.test-workspace/revm-hardhat-examples/uniswap-v3-periphery-hardhat/node_modules
32+
key: ${{ runner.os }}-uniswap-v3-periphery-hardhat-npm-${{ hashFiles('polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/tests/docs.test.ts') }}
33+
34+
- name: Install wrapper dependencies
35+
run: |
36+
cd polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat
37+
npm ci
38+
39+
- name: Run tests
40+
run: |
41+
cd polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat
42+
npm test
43+
env:
44+
TESTNET_PRIVATE_KEY: ${{ secrets.TESTNET_PRIVATE_KEY }}
45+
timeout-minutes: 30
46+
47+
post-test:
48+
needs: test
49+
if: github.repository == 'polkadot-developers/polkadot-cookbook' && always() && github.ref == 'refs/heads/master'
50+
uses: ./.github/workflows/post-cleanup.yml
51+
with:
52+
test_result: ${{ needs.test.result }}
53+
readme_path: 'polkadot-docs/smart-contracts/uniswap-v3-periphery-hardhat/README.md'
54+
workflow_name: 'Uniswap V3 Periphery with Hardhat'
55+
permissions:
56+
contents: read
57+
issues: write

polkadot-docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ This repository serves as the **source of truth** that Polkadot documentation wo
6262
| [Uniswap V2 Core with Hardhat](./smart-contracts/uniswap-v2-core-hardhat/) | [![Uniswap V2 Core with Hardhat](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v2-core-hardhat.yml/badge.svg?event=push)](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v2-core-hardhat.yml) | [docs.polkadot.com](https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v2/core-v2/) |
6363
| [Uniswap V2 Periphery with Hardhat](./smart-contracts/uniswap-v2-periphery-hardhat/) | [![Uniswap V2 Periphery with Hardhat](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v2-periphery-hardhat.yml/badge.svg?event=push)](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v2-periphery-hardhat.yml) | [docs.polkadot.com](https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v2/periphery-v2/) |
6464
| [Uniswap V3 Core with Hardhat](./smart-contracts/uniswap-v3-core-hardhat/) | [![Uniswap V3 Core with Hardhat](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v3-core-hardhat.yml/badge.svg?event=push)](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v3-core-hardhat.yml) | [docs.polkadot.com](https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v3/core-v3/) |
65+
| [Uniswap V3 Periphery with Hardhat](./smart-contracts/uniswap-v3-periphery-hardhat/) | [![Uniswap V3 Periphery with Hardhat](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v3-periphery-hardhat.yml/badge.svg?event=push)](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v3-periphery-hardhat.yml) | [docs.polkadot.com](https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v3/periphery-v3/) |
6566

6667
## How It Works
6768

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.test-workspace/
2+
node_modules/
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: "Uniswap V3 Periphery with Hardhat"
3+
description: "Verify the Uniswap V3 Periphery with Hardhat guide from docs.polkadot.com"
4+
source_url: "https://docs.polkadot.com/smart-contracts/cookbook/eth-dapps/uniswap-v3/periphery-v3/"
5+
source_repo: "https://github.com/polkadot-developers/polkadot-docs/blob/master/smart-contracts/cookbook/eth-dapps/uniswap-v3/periphery-v3.md"
6+
---
7+
8+
# Uniswap V3 Periphery with Hardhat
9+
10+
[![Uniswap V3 Periphery with Hardhat](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v3-periphery-hardhat.yml/badge.svg?event=push)](https://github.com/polkadot-developers/polkadot-cookbook/actions/workflows/polkadot-docs-uniswap-v3-periphery-hardhat.yml)
11+
12+
This project verifies the Uniswap V3 Periphery with Hardhat guide from docs.polkadot.com.
13+
14+
The tests run against [revm-hardhat-examples](https://github.com/polkadot-developers/revm-hardhat-examples) at a pinned commit, compiling and testing the Uniswap V3 Periphery contracts (SwapRouter and NonfungiblePositionManager) on Hardhat's local network and deploying all four contracts via Hardhat Ignition to Polkadot Hub TestNet.
15+
16+
## What This Tests
17+
18+
1. **Environment Prerequisites** - Verifies Node.js v22+, npm, and git are available
19+
2. **Clone Repository** - Clones `revm-hardhat-examples` at the pinned commit and verifies the expected project structure (SwapRouter, NonfungiblePositionManager, Ignition module)
20+
3. **Install Dependencies** - Installs `uniswap-v3-periphery-hardhat` dependencies (resolves the local `@uniswap/v3-core` file reference automatically) and confirms Hardhat is available
21+
4. **Configure Testnet Credentials** - Verifies `TESTNET_PRIVATE_KEY` is available (skipped when not set)
22+
5. **Compile Contracts** - Runs `npx hardhat compile` and verifies the `SwapRouter.json` and `NonfungiblePositionManager.json` artifacts (ABI + bytecode)
23+
6. **Run Hardhat Tests** - Runs the full Hardhat test suite (39 tests: 14 SwapRouter + 25 NFPM) on the local Hardhat network
24+
7. **Deploy via Ignition** - Deploys UniswapV3Factory, WETH9, SwapRouter, and NonfungiblePositionManager using Hardhat Ignition to `polkadotTestnet` and verifies contract addresses are returned
25+
26+
## Prerequisites
27+
28+
- Node.js v22.13.1 or later
29+
- npm
30+
- git
31+
- A funded account on Polkadot Hub TestNet (get tokens from the [Polkadot Faucet](https://faucet.polkadot.io/))
32+
33+
## Running Tests Locally
34+
35+
```bash
36+
# 1. Export testnet private key (RPC URL is hardcoded in hardhat.config.ts)
37+
export TESTNET_PRIVATE_KEY="<your-private-key>"
38+
39+
# 2. Install wrapper dependencies
40+
npm install
41+
42+
# 3. Run all verification tests
43+
npm test
44+
```
45+
46+
## Environment Variables
47+
48+
| Variable | Description |
49+
|---|---|
50+
| `TESTNET_PRIVATE_KEY` | Private key of a funded account (no `0x` prefix) |

0 commit comments

Comments
 (0)