Skip to content

Commit 6d27412

Browse files
authored
Merge pull request #1 from ten-protocol/staging/vercel-fixes
fix(build): various fixes
2 parents d79cd3a + 2759778 commit 6d27412

78 files changed

Lines changed: 13502 additions & 10402 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(yarn build)",
5+
"Bash(npx tsc:*)",
6+
"Bash(findstr:*)"
7+
]
8+
}
9+
}

.env.production

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
REACT_APP_CHAIN_ID=
22
REACT_APP_NETWORK_URL=
3+
REACT_APP_FACTORY_ADDRESS=0x33c19B8ACb01deaEA5906c4de408474e0FB81081
4+
REACT_APP_ROUTER_ADDRESS=0x9DD8d152B3335d1174eF57B84578fFF84bc8Aa08
5+
REACT_APP_MULTICALL_ADDRESS=0x29A8E964a4e220e3438e39dDDd01B4A3305A7c54
6+
REACT_APP_INIT_CODE_HASH=0x7a4225208e47ab2fd985ee6462c9841d21f9f4adfde4aa02690f7ba65dc67d56
7+
REACT_APP_ALPHA_TOKEN_ADDRESS=0xECbc08c2f0b19E1c43Df4aB984431B0FCFB015D0
8+
REACT_APP_BETA_TOKEN_ADDRESS=0x81c489820D3c03AB694d38120FC69B7233fe530B
9+
REACT_APP_WETH_ADDRESS=0x1000000000000000000000000000000000000042
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Deploy Contracts to TEN Testnet
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
weth_address:
7+
description: 'WETH contract address'
8+
required: false
9+
default: '0x1000000000000000000000000000000000000042'
10+
eth_per_pool:
11+
description: 'ETH per liquidity pool (e.g. 0.5)'
12+
required: false
13+
default: '0.5'
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: contracts
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '18'
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Compile contracts
35+
run: npx hardhat compile
36+
37+
- name: Deploy contracts
38+
id: deploy
39+
env:
40+
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
41+
TEN_TESTNET_RPC: ${{ secrets.TEN_TESTNET_RPC }}
42+
WETH_ADDRESS: ${{ inputs.weth_address }}
43+
ETH_PER_POOL: ${{ inputs.eth_per_pool }}
44+
run: |
45+
npx hardhat run scripts/deploy.ts --network ten_testnet 2>&1 | tee deploy_output.txt
46+
47+
# Parse deployed addresses from deployment JSON
48+
DEPLOY_JSON=$(ls -t deployments/deployment-*.json 2>/dev/null | head -1)
49+
if [ -z "$DEPLOY_JSON" ]; then
50+
echo "::error::No deployment JSON found"
51+
exit 1
52+
fi
53+
54+
echo "deployment_file=$DEPLOY_JSON" >> "$GITHUB_OUTPUT"
55+
56+
# Extract addresses for the summary
57+
echo "factory=$(jq -r '.contracts.factory' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
58+
echo "router=$(jq -r '.contracts.router' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
59+
echo "alpha=$(jq -r '.contracts.alphaToken' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
60+
echo "beta=$(jq -r '.contracts.betaToken' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
61+
echo "weth=$(jq -r '.contracts.weth' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
62+
echo "init_hash=$(jq -r '.initCodeHash' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
63+
echo "pool_alpha_weth=$(jq -r '.pools.alphaWeth' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
64+
echo "pool_beta_weth=$(jq -r '.pools.betaWeth' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
65+
echo "pool_alpha_beta=$(jq -r '.pools.alphaBeta' "$DEPLOY_JSON")" >> "$GITHUB_OUTPUT"
66+
67+
- name: Print Vercel environment variables
68+
env:
69+
FACTORY: ${{ steps.deploy.outputs.factory }}
70+
ROUTER: ${{ steps.deploy.outputs.router }}
71+
ALPHA: ${{ steps.deploy.outputs.alpha }}
72+
BETA: ${{ steps.deploy.outputs.beta }}
73+
WETH: ${{ steps.deploy.outputs.weth }}
74+
INIT_HASH: ${{ steps.deploy.outputs.init_hash }}
75+
POOL_AW: ${{ steps.deploy.outputs.pool_alpha_weth }}
76+
POOL_BW: ${{ steps.deploy.outputs.pool_beta_weth }}
77+
POOL_AB: ${{ steps.deploy.outputs.pool_alpha_beta }}
78+
run: |
79+
echo ""
80+
echo "============================================"
81+
echo " UPDATE THESE IN VERCEL ENV VARIABLES"
82+
echo "============================================"
83+
echo ""
84+
cat <<EOF
85+
{
86+
"REACT_APP_FACTORY_ADDRESS": "$FACTORY",
87+
"REACT_APP_ROUTER_ADDRESS": "$ROUTER",
88+
"REACT_APP_ALPHA_TOKEN_ADDRESS": "$ALPHA",
89+
"REACT_APP_BETA_TOKEN_ADDRESS": "$BETA",
90+
"REACT_APP_WETH_ADDRESS": "$WETH",
91+
"REACT_APP_INIT_CODE_HASH": "$INIT_HASH"
92+
}
93+
EOF
94+
echo ""
95+
echo "Liquidity Pools:"
96+
echo " ALPHA/WETH: $POOL_AW"
97+
echo " BETA/WETH: $POOL_BW"
98+
echo " ALPHA/BETA: $POOL_AB"
99+
echo ""
100+
echo "============================================"
101+
echo " Copy the JSON above into Vercel:"
102+
echo " Project Settings > Environment Variables"
103+
echo "============================================"
104+
105+
- name: Job summary
106+
env:
107+
FACTORY: ${{ steps.deploy.outputs.factory }}
108+
ROUTER: ${{ steps.deploy.outputs.router }}
109+
ALPHA: ${{ steps.deploy.outputs.alpha }}
110+
BETA: ${{ steps.deploy.outputs.beta }}
111+
WETH: ${{ steps.deploy.outputs.weth }}
112+
INIT_HASH: ${{ steps.deploy.outputs.init_hash }}
113+
POOL_AW: ${{ steps.deploy.outputs.pool_alpha_weth }}
114+
POOL_BW: ${{ steps.deploy.outputs.pool_beta_weth }}
115+
POOL_AB: ${{ steps.deploy.outputs.pool_alpha_beta }}
116+
run: |
117+
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
118+
## Contract Deployment Results
119+
120+
### Vercel Environment Variables
121+
122+
Copy this JSON into **Vercel > Project Settings > Environment Variables**:
123+
124+
\`\`\`json
125+
{
126+
"REACT_APP_FACTORY_ADDRESS": "$FACTORY",
127+
"REACT_APP_ROUTER_ADDRESS": "$ROUTER",
128+
"REACT_APP_ALPHA_TOKEN_ADDRESS": "$ALPHA",
129+
"REACT_APP_BETA_TOKEN_ADDRESS": "$BETA",
130+
"REACT_APP_WETH_ADDRESS": "$WETH",
131+
"REACT_APP_INIT_CODE_HASH": "$INIT_HASH"
132+
}
133+
\`\`\`
134+
135+
### Deployed Contracts
136+
137+
| Contract | Address |
138+
|----------|---------|
139+
| Factory | \`$FACTORY\` |
140+
| Router | \`$ROUTER\` |
141+
| ALPHA | \`$ALPHA\` |
142+
| BETA | \`$BETA\` |
143+
| WETH | \`$WETH\` |
144+
145+
### Liquidity Pools
146+
147+
| Pair | Address |
148+
|------|---------|
149+
| ALPHA/WETH | \`$POOL_AW\` |
150+
| BETA/WETH | \`$POOL_BW\` |
151+
| ALPHA/BETA | \`$POOL_AB\` |
152+
153+
### Configuration
154+
155+
- **Init Code Hash**: \`$INIT_HASH\`
156+
- **ETH per pool**: ${{ inputs.eth_per_pool }}
157+
- **WETH address**: ${{ inputs.weth_address }}
158+
EOF
159+
160+
- name: Upload deployment artifact
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: deployment-result
164+
path: contracts/deployments/
165+
retention-days: 90

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# dependencies
44
/node_modules
5+
yarn.lock
56

67
# testing
78
/coverage
@@ -11,6 +12,7 @@
1112

1213
# misc
1314
.DS_Store
15+
.env
1416
.env.local
1517
.env.development.local
1618
.env.test.local
@@ -31,4 +33,12 @@ package-lock.json
3133

3234
cypress/videos
3335
cypress/screenshots
34-
cypress/fixtures/example.json
36+
cypress/fixtures/example.json
37+
38+
# contracts subdirectory
39+
contracts/node_modules/
40+
contracts/artifacts/
41+
contracts/cache/
42+
contracts/typechain-types/
43+
contracts/deployments/
44+
contracts/.env

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"semi": false,
33
"singleQuote": true,
4-
"printWidth": 120
4+
"printWidth": 120,
5+
"endOfLine": "auto"
56
}

README.md

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ yarn
1919
```bash
2020
REACT_APP_CHAIN_ID="8443"
2121
REACT_APP_NETWORK_URL="https://testnet.ten.xyz/v1/?token=YOUR_TEN_GATEWAY_TOKEN"
22+
REACT_APP_FACTORY_ADDRESS=0x38b8773E1B048fbBb4f4620b2861db8703aBE7b9
23+
REACT_APP_ROUTER_ADDRESS=0x9cF6C659F173916f4928420E72DE53E667DbDf73
24+
REACT_APP_MULTICALL_ADDRESS=0x29A8E964a4e220e3438e39dDDd01B4A3305A7c54
25+
REACT_APP_INIT_CODE_HASH=0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f
26+
REACT_APP_ALPHA_TOKEN_ADDRESS=0x910c2a26649063a37fc507EC827fF7f6784133a1
27+
REACT_APP_BETA_TOKEN_ADDRESS=0xD3C60e71391b8F481222546c80F046a73AA4611f
28+
REACT_APP_WETH_ADDRESS=0x0000000000000000000000000000000000000001
2229
```
2330

2431
### Run
@@ -27,15 +34,76 @@ REACT_APP_NETWORK_URL="https://testnet.ten.xyz/v1/?token=YOUR_TEN_GATEWAY_TOKEN"
2734
yarn start
2835
```
2936

37+
## Contract Deployment
38+
39+
The `contracts/` directory contains a self-contained Hardhat project for deploying the full Uniswap V2 suite to TEN Testnet.
40+
41+
### Setup
42+
43+
```bash
44+
cd contracts
45+
npm install
46+
cp .env.example .env
47+
```
48+
49+
Edit `contracts/.env` with your deployer private key and RPC URL:
50+
51+
```bash
52+
DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
53+
TEN_TESTNET_RPC=https://testnet-rpc.ten.xyz/v1/?token=YOUR_TOKEN_HERE
54+
WETH_ADDRESS=0x1000000000000000000000000000000000000042
55+
ETH_PER_POOL=0.5
56+
```
57+
58+
### Compile
59+
60+
```bash
61+
npx hardhat compile
62+
```
63+
64+
### Deploy
65+
66+
```bash
67+
npx hardhat run scripts/deploy.ts --network ten_testnet
68+
```
69+
70+
The deploy script will:
71+
72+
1. Deploy UniswapV2Factory
73+
2. Compute and verify the init code hash
74+
3. Deploy UniswapV2Router02
75+
4. Deploy ALPHA token (100M supply)
76+
5. Deploy BETA token (100M supply)
77+
6. Create ALPHA/WETH pool (50M ALPHA + ETH)
78+
7. Create BETA/WETH pool (50M BETA + ETH)
79+
8. Create ALPHA/BETA pool (50M ALPHA + 50M BETA)
80+
9. Auto-update the root `.env` and `.env.production` with new addresses
81+
82+
### Utility Scripts
83+
84+
```bash
85+
# Compute init code hash from compiled UniswapV2Pair bytecode
86+
npx hardhat run scripts/compute-init-hash.ts
87+
```
88+
89+
You can also run these from the project root:
90+
91+
```bash
92+
yarn contracts:install
93+
yarn contracts:compile
94+
yarn contracts:deploy
95+
yarn contracts:compute-hash
96+
```
97+
3098
## Deployed Contracts (TEN Testnet)
3199

32-
| Contract | Address |
33-
|----------|---------|
34-
| Factory | `0x38b8773E1B048fbBb4f4620b2861db8703aBE7b9` |
35-
| Router | `0x9cF6C659F173916f4928420E72DE53E667DbDf73` |
36-
| Multicall | `0x29A8E964a4e220e3438e39dDDd01B4A3305A7c54` |
100+
| Contract | Address |
101+
| ----------- | ---------------------------------------------- |
102+
| Factory | `0x38b8773E1B048fbBb4f4620b2861db8703aBE7b9` |
103+
| Router | `0x9cF6C659F173916f4928420E72DE53E667DbDf73` |
104+
| Multicall | `0x29A8E964a4e220e3438e39dDDd01B4A3305A7c54` |
37105
| ALPHA Token | `0x910c2a26649063a37fc507EC827fF7f6784133a1` |
38-
| BETA Token | `0xD3C60e71391b8F481222546c80F046a73AA4611f` |
106+
| BETA Token | `0xD3C60e71391b8F481222546c80F046a73AA4611f` |
39107

40108
## Network Details
41109

contracts/.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Deployer wallet private key (must be funded with ETH on TEN Testnet)
2+
DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
3+
4+
# TEN Testnet RPC URL
5+
TEN_TESTNET_RPC=https://testnet-rpc.ten.xyz/v1/?token=YOUR_TOKEN_HERE
6+
7+
# WETH address (TEN Testnet precompile)
8+
WETH_ADDRESS=0x1000000000000000000000000000000000000042
9+
10+
# ETH to seed each ETH pool (ALPHA/WETH and BETA/WETH)
11+
ETH_PER_POOL=0.5

contracts/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
artifacts/
3+
cache/
4+
dist/
5+
typechain-types/
6+
deployments/
7+
.env

0 commit comments

Comments
 (0)