Skip to content

Commit 1652013

Browse files
razwwclaude
andcommitted
chore: add deployment + smoke-test scripts and BSC testnet record
- scripts/deploy.ts: deploy Factory + Router02, write deployments/<net>.json, and assert keccak256(ListaV2Pair.creationCode) == library init-code hash - scripts/create-pair.ts: create a pair (env TOKEN_A/TOKEN_B), verify the on-chain address matches the CREATE2 derivation - scripts/smoke-test.ts: read-only smoke tests + init-code-hash verification - scripts/smoke-swap.ts: live add-liquidity + swap E2E (both token and native paths) - scripts/lib/deployments.ts: load/save deployment records - deployments/bscTestnet.json: deployed + verified Factory/Router02/WBNB-USDT pair - hardhat.config.ts: bscTestnet network + Etherscan V2 verification; load .env - README: Deployment section + BSC testnet addresses .env is gitignored (never committed). Full suite: 126 passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 08f460e commit 1652013

10 files changed

Lines changed: 511 additions & 0 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,46 @@ npm run compile # hardhat compile
6464
npm test # hardhat test
6565
```
6666

67+
## Deployment
68+
69+
Scripts live in `scripts/` and record addresses to `deployments/<network>.json`.
70+
Configure `.env` (see the keys read by `hardhat.config.ts`): `PRIVATE_KEY_TESTNET`,
71+
`BSC_TESTNET_RPC_URL`, and `ETHERSCAN_API_KEY` (Etherscan V2 unified key, used for
72+
BscScan verification).
73+
74+
```bash
75+
# deploy Factory + Router02 and write deployments/<net>.json
76+
npx hardhat run scripts/deploy.ts --network bscTestnet
77+
78+
# create a pair (defaults WBNB/USDT; override TOKEN_A / TOKEN_B)
79+
npx hardhat run scripts/create-pair.ts --network bscTestnet
80+
81+
# verify on the block explorer (Etherscan V2 API)
82+
npx hardhat verify --network bscTestnet <factory> <feeToSetter>
83+
npx hardhat verify --network bscTestnet <router> <factory> <WETH>
84+
85+
# read-only smoke tests + init-code-hash check
86+
npx hardhat run scripts/smoke-test.ts --network bscTestnet
87+
# live end-to-end (adds liquidity + swaps; spends testnet funds)
88+
npx hardhat run scripts/smoke-swap.ts --network bscTestnet
89+
```
90+
91+
`ListaV2Pair` is never deployed directly — the factory creates it via CREATE2, so
92+
`scripts/deploy.ts` verifies `keccak256(type(ListaV2Pair).creationCode)` matches the
93+
hash hardcoded in `ListaV2Library.pairFor`. Production deployments must use the exact
94+
compiler settings in `hardhat.config.ts` (solc 0.5.16, optimizer 999999, istanbul),
95+
or that hash — and every derived pair address — changes.
96+
97+
### BSC testnet (chainId 97)
98+
99+
| Contract | Address |
100+
| --- | --- |
101+
| ListaV2Factory | `0xD5397504095C424325416f0c83c42F5805626c54` |
102+
| ListaV2Router02 | `0x0B8306e6ad72Bf95538feB9fc29C8673eAe5785f` |
103+
| Pair WBNB/USDT | `0xd3ECad4ef152727581c238Fe73cE7443293Cb99B` |
104+
105+
All three are verified on [testnet.bscscan.com](https://testnet.bscscan.com).
106+
67107
## License
68108

69109
GPL-3.0-or-later (unchanged from upstream).

deployments/bscTestnet.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"network": "bscTestnet",
3+
"chainId": 97,
4+
"deployer": "0x6616EF47F4d997137a04C2AD7FF8e5c228dA4f06",
5+
"feeToSetter": "0x6616EF47F4d997137a04C2AD7FF8e5c228dA4f06",
6+
"factory": "0xD5397504095C424325416f0c83c42F5805626c54",
7+
"router02": "0x0B8306e6ad72Bf95538feB9fc29C8673eAe5785f",
8+
"WETH": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
9+
"pairInitCodeHash": "0x20adb33eb0c20d289945602eca3d6797bfe1b2555b1f251a8855fc5bb3ceea3d",
10+
"pairs": {
11+
"WBNB/USDT": {
12+
"address": "0xd3ECad4ef152727581c238Fe73cE7443293Cb99B",
13+
"token0": "0x49b1401B4406Fe0B32481613bF1bC9Fe4B9378aC",
14+
"token1": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd"
15+
}
16+
}
17+
}

hardhat.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { HardhatUserConfig } from "hardhat/config";
22
import "@nomiclabs/hardhat-waffle";
3+
import "@nomicfoundation/hardhat-verify";
4+
import * as dotenv from "dotenv";
5+
6+
dotenv.config();
7+
8+
// Normalize the deployer key (hardhat wants a 0x-prefixed hex private key).
9+
const rawKey = process.env.PRIVATE_KEY_TESTNET || "";
10+
const testnetKey = rawKey ? [rawKey.startsWith("0x") ? rawKey : `0x${rawKey}`] : [];
11+
const bscTestnetRpc =
12+
process.env.BSC_TESTNET_RPC_URL || "https://bsc-testnet-dataseed.bnbchain.org";
313

414
/**
515
* Uniswap V2 uses two Solidity versions:
@@ -34,6 +44,15 @@ const config: HardhatUserConfig = {
3444
// setup txs don't drift past the anchored start time.
3545
allowBlocksWithSameTimestamp: true,
3646
},
47+
bscTestnet: {
48+
url: bscTestnetRpc,
49+
chainId: 97,
50+
accounts: testnetKey,
51+
},
52+
},
53+
etherscan: {
54+
// Etherscan V2 unified API — a single key routes to BSC by chainId.
55+
apiKey: process.env.ETHERSCAN_API_KEY || process.env.BSCSCAN_API_KEY || "",
3756
},
3857
paths: {
3958
sources: "./contracts",

package-lock.json

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
"@uniswap/lib": "4.0.1-alpha"
1616
},
1717
"devDependencies": {
18+
"@nomicfoundation/hardhat-verify": "^2.1.3",
1819
"@nomiclabs/hardhat-ethers": "^2.2.3",
1920
"@nomiclabs/hardhat-waffle": "^2.0.6",
2021
"@types/chai": "^4.3.20",
2122
"@types/mocha": "^9.1.1",
2223
"@types/node": "^20.19.43",
2324
"chai": "^4.5.0",
25+
"dotenv": "^17.4.2",
2426
"ethereum-waffle": "^3.4.4",
2527
"ethereumjs-util": "^6.2.1",
2628
"ethers": "^5.8.0",

0 commit comments

Comments
 (0)