Skip to content

Commit 005a3ad

Browse files
gHashTagclaude
andcommitted
feat: $TRI DEX Launch - Smart Contract & Uniswap V3 Scripts
Smart Contract: - contracts/TrinityToken.sol: ERC-20 + ERC-20Permit - Built-in vesting for all allocations - Phi identity verification on deploy - OpenZeppelin base (battle-tested) Deployment Scripts: - contracts/scripts/deploy.js: Token deployment - contracts/scripts/create-pool.js: Uniswap V3 pool - contracts/scripts/add-liquidity.js: Add liquidity Configuration: - contracts/hardhat.config.js: Mainnet + Sepolia - contracts/package.json: Dependencies - contracts/.env.example: Environment template Pool Parameters: - Pair: TRI/WETH - Fee: 0.3% - TRI: 523M - ETH: 1,494 (~$5.23M) - Price: $0.01 initial 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8f60757 commit 005a3ad

8 files changed

Lines changed: 1278 additions & 0 deletions

File tree

contracts/.env.example

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Trinity Token ($TRI) Deployment Environment Variables
2+
# Copy this to .env and fill in real values
3+
4+
# ═══════════════════════════════════════════════════════════════════════════════
5+
# REQUIRED: Deployer Wallet
6+
# ═══════════════════════════════════════════════════════════════════════════════
7+
8+
# Private key of deployer wallet (WITH 0x prefix)
9+
# This wallet needs:
10+
# - ~0.5 ETH for deployment gas
11+
# - 1,494+ ETH for liquidity pool
12+
PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000
13+
14+
# ═══════════════════════════════════════════════════════════════════════════════
15+
# REQUIRED: RPC URLs
16+
# ═══════════════════════════════════════════════════════════════════════════════
17+
18+
# Ethereum Mainnet RPC (Alchemy or Infura)
19+
# Get free: https://alchemy.com or https://infura.io
20+
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY
21+
22+
# Sepolia Testnet RPC (for testing)
23+
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR-API-KEY
24+
25+
# ═══════════════════════════════════════════════════════════════════════════════
26+
# REQUIRED: Etherscan API Key (for verification)
27+
# ═══════════════════════════════════════════════════════════════════════════════
28+
29+
# Get free: https://etherscan.io/apis
30+
ETHERSCAN_API_KEY=YOUR-ETHERSCAN-API-KEY
31+
32+
# ═══════════════════════════════════════════════════════════════════════════════
33+
# REQUIRED: Allocation Addresses
34+
# ═══════════════════════════════════════════════════════════════════════════════
35+
36+
# Founder & Team (20%) - 4yr vesting, 1yr cliff
37+
FOUNDER_ADDRESS=0x0000000000000000000000000000000000000000
38+
39+
# Node Rewards Pool (40%) - 10yr vesting
40+
NODE_REWARDS_ADDRESS=0x0000000000000000000000000000000000000000
41+
42+
# Community & Ecosystem (20%) - 3yr vesting
43+
COMMUNITY_ADDRESS=0x0000000000000000000000000000000000000000
44+
45+
# Treasury & Development (10%) - 5yr vesting, 6mo cliff
46+
TREASURY_ADDRESS=0x0000000000000000000000000000000000000000
47+
48+
# Liquidity (10%) - Immediate, for Uniswap pool
49+
LIQUIDITY_ADDRESS=0x0000000000000000000000000000000000000000
50+
51+
# ═══════════════════════════════════════════════════════════════════════════════
52+
# OPTIONAL: After Deployment
53+
# ═══════════════════════════════════════════════════════════════════════════════
54+
55+
# Set after running deploy.js
56+
TRI_TOKEN_ADDRESS=
57+
58+
# Set after running create-pool.js
59+
POOL_ADDRESS=
60+
61+
# ═══════════════════════════════════════════════════════════════════════════════
62+
# KOSCHEI IS IMMORTAL | φ² + 1/φ² = 3
63+
# ═══════════════════════════════════════════════════════════════════════════════

contracts/TrinityToken.sol

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5+
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
6+
7+
/**
8+
* @title Trinity Token ($TRI)
9+
* @notice Green Ternary AI Network Token
10+
* @dev Total Supply: 3^21 = 10,460,353,203 TRI (Phoenix Number)
11+
*
12+
* Tokenomics:
13+
* - Founder & Team: 20% (2,092,070,640) - 4yr vest, 1yr cliff
14+
* - Node Rewards: 40% (4,184,141,281) - 10yr vest
15+
* - Community: 20% (2,092,070,640) - 3yr vest
16+
* - Treasury: 10% (1,046,035,320) - 5yr vest, 6mo cliff
17+
* - Liquidity: 10% (1,046,035,320) - Immediate
18+
*
19+
* Sacred Formula: phi^2 + 1/phi^2 = 3 (Trinity Identity)
20+
* KOSCHEI IS IMMORTAL
21+
*/
22+
contract TrinityToken is ERC20, ERC20Permit {
23+
/// @notice Phoenix Number: 3^21 = Total Supply
24+
uint256 public constant PHOENIX_NUMBER = 10_460_353_203;
25+
26+
/// @notice Total supply with 18 decimals
27+
uint256 public constant TOTAL_SUPPLY = PHOENIX_NUMBER * 10**18;
28+
29+
/// @notice Golden ratio (scaled by 1e18)
30+
uint256 public constant PHI_SCALED = 1_618033988749895000;
31+
32+
/// @notice Genesis timestamp
33+
uint256 public immutable genesisTimestamp;
34+
35+
/// @notice Allocation addresses
36+
address public immutable founderAddress;
37+
address public immutable nodeRewardsAddress;
38+
address public immutable communityAddress;
39+
address public immutable treasuryAddress;
40+
address public immutable liquidityAddress;
41+
42+
/// @notice Allocation amounts
43+
uint256 public constant FOUNDER_ALLOCATION = TOTAL_SUPPLY * 20 / 100;
44+
uint256 public constant NODE_REWARDS_ALLOCATION = TOTAL_SUPPLY * 40 / 100;
45+
uint256 public constant COMMUNITY_ALLOCATION = TOTAL_SUPPLY * 20 / 100;
46+
uint256 public constant TREASURY_ALLOCATION = TOTAL_SUPPLY * 10 / 100;
47+
uint256 public constant LIQUIDITY_ALLOCATION = TOTAL_SUPPLY * 10 / 100;
48+
49+
/// @notice Vesting tracking
50+
mapping(address => uint256) public vestingStart;
51+
mapping(address => uint256) public vestingDuration;
52+
mapping(address => uint256) public cliffDuration;
53+
mapping(address => uint256) public totalVested;
54+
mapping(address => uint256) public claimed;
55+
56+
event AllocationClaimed(address indexed beneficiary, uint256 amount);
57+
event PhiVerified(uint256 result);
58+
59+
/**
60+
* @notice Deploy Trinity Token
61+
* @param _founder Founder & Team address
62+
* @param _nodeRewards Node Rewards pool address
63+
* @param _community Community address
64+
* @param _treasury Treasury address
65+
* @param _liquidity Liquidity address (receives tokens immediately)
66+
*/
67+
constructor(
68+
address _founder,
69+
address _nodeRewards,
70+
address _community,
71+
address _treasury,
72+
address _liquidity
73+
) ERC20("Trinity", "TRI") ERC20Permit("Trinity") {
74+
require(_founder != address(0), "Invalid founder");
75+
require(_nodeRewards != address(0), "Invalid nodeRewards");
76+
require(_community != address(0), "Invalid community");
77+
require(_treasury != address(0), "Invalid treasury");
78+
require(_liquidity != address(0), "Invalid liquidity");
79+
80+
genesisTimestamp = block.timestamp;
81+
82+
founderAddress = _founder;
83+
nodeRewardsAddress = _nodeRewards;
84+
communityAddress = _community;
85+
treasuryAddress = _treasury;
86+
liquidityAddress = _liquidity;
87+
88+
// Setup vesting
89+
_setupVesting(_founder, FOUNDER_ALLOCATION, 48 * 30 days, 12 * 30 days);
90+
_setupVesting(_nodeRewards, NODE_REWARDS_ALLOCATION, 120 * 30 days, 0);
91+
_setupVesting(_community, COMMUNITY_ALLOCATION, 36 * 30 days, 0);
92+
_setupVesting(_treasury, TREASURY_ALLOCATION, 60 * 30 days, 6 * 30 days);
93+
94+
// Mint liquidity immediately (no vesting)
95+
_mint(_liquidity, LIQUIDITY_ALLOCATION);
96+
97+
// Verify phi identity on deploy
98+
_verifyPhiIdentity();
99+
}
100+
101+
/**
102+
* @notice Setup vesting for an allocation
103+
*/
104+
function _setupVesting(
105+
address beneficiary,
106+
uint256 amount,
107+
uint256 duration,
108+
uint256 cliff
109+
) internal {
110+
vestingStart[beneficiary] = block.timestamp;
111+
vestingDuration[beneficiary] = duration;
112+
cliffDuration[beneficiary] = cliff;
113+
totalVested[beneficiary] = amount;
114+
}
115+
116+
/**
117+
* @notice Calculate vested amount for an address
118+
*/
119+
function vestedAmount(address beneficiary) public view returns (uint256) {
120+
if (totalVested[beneficiary] == 0) return 0;
121+
122+
uint256 elapsed = block.timestamp - vestingStart[beneficiary];
123+
124+
// Before cliff
125+
if (elapsed < cliffDuration[beneficiary]) {
126+
return 0;
127+
}
128+
129+
// After full vesting
130+
if (elapsed >= vestingDuration[beneficiary]) {
131+
return totalVested[beneficiary];
132+
}
133+
134+
// During vesting (linear)
135+
return (totalVested[beneficiary] * elapsed) / vestingDuration[beneficiary];
136+
}
137+
138+
/**
139+
* @notice Claim vested tokens
140+
*/
141+
function claimVested() external {
142+
uint256 vested = vestedAmount(msg.sender);
143+
uint256 claimable = vested - claimed[msg.sender];
144+
145+
require(claimable > 0, "Nothing to claim");
146+
147+
claimed[msg.sender] = vested;
148+
_mint(msg.sender, claimable);
149+
150+
emit AllocationClaimed(msg.sender, claimable);
151+
}
152+
153+
/**
154+
* @notice Get claimable amount
155+
*/
156+
function claimableAmount(address beneficiary) external view returns (uint256) {
157+
return vestedAmount(beneficiary) - claimed[beneficiary];
158+
}
159+
160+
/**
161+
* @notice Verify phi^2 + 1/phi^2 = 3 (Trinity Identity)
162+
* @dev Uses scaled integers: phi = 1.618... * 1e18
163+
*/
164+
function _verifyPhiIdentity() internal {
165+
// phi^2 = 2.618... * 1e18
166+
uint256 phiSquared = (PHI_SCALED * PHI_SCALED) / 1e18;
167+
168+
// 1/phi^2 = 0.381... * 1e18
169+
uint256 invPhiSquared = (1e36) / phiSquared;
170+
171+
// phi^2 + 1/phi^2 should be ~3 * 1e18
172+
uint256 result = phiSquared + invPhiSquared;
173+
174+
// Allow 0.01% tolerance
175+
require(
176+
result > 2_999_000_000_000_000_000 && result < 3_001_000_000_000_000_000,
177+
"Trinity identity failed"
178+
);
179+
180+
emit PhiVerified(result);
181+
}
182+
183+
/**
184+
* @notice Get circulating supply (minted - burned)
185+
*/
186+
function circulatingSupply() external view returns (uint256) {
187+
return totalSupply();
188+
}
189+
190+
/**
191+
* @notice Get remaining to vest for an address
192+
*/
193+
function remainingVesting(address beneficiary) external view returns (uint256) {
194+
return totalVested[beneficiary] - vestedAmount(beneficiary);
195+
}
196+
}

contracts/hardhat.config.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
require("@nomicfoundation/hardhat-toolbox");
2+
require("dotenv").config();
3+
4+
/**
5+
* Trinity Token ($TRI) Hardhat Configuration
6+
* Deploy to Ethereum Mainnet & Sepolia Testnet
7+
*
8+
* Required Environment Variables:
9+
* - PRIVATE_KEY: Deployer wallet private key
10+
* - ETHERSCAN_API_KEY: For contract verification
11+
* - MAINNET_RPC_URL: Ethereum mainnet RPC (Alchemy/Infura)
12+
* - SEPOLIA_RPC_URL: Sepolia testnet RPC
13+
*/
14+
15+
const PRIVATE_KEY = process.env.PRIVATE_KEY || "0x0000000000000000000000000000000000000000000000000000000000000001";
16+
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || "";
17+
const MAINNET_RPC_URL = process.env.MAINNET_RPC_URL || "https://eth-mainnet.g.alchemy.com/v2/your-api-key";
18+
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL || "https://eth-sepolia.g.alchemy.com/v2/your-api-key";
19+
20+
module.exports = {
21+
solidity: {
22+
version: "0.8.20",
23+
settings: {
24+
optimizer: {
25+
enabled: true,
26+
runs: 200
27+
}
28+
}
29+
},
30+
networks: {
31+
hardhat: {
32+
chainId: 31337,
33+
forking: {
34+
url: MAINNET_RPC_URL,
35+
enabled: false
36+
}
37+
},
38+
localhost: {
39+
url: "http://127.0.0.1:8545",
40+
chainId: 31337
41+
},
42+
sepolia: {
43+
url: SEPOLIA_RPC_URL,
44+
accounts: [PRIVATE_KEY],
45+
chainId: 11155111,
46+
gasPrice: "auto"
47+
},
48+
mainnet: {
49+
url: MAINNET_RPC_URL,
50+
accounts: [PRIVATE_KEY],
51+
chainId: 1,
52+
gasPrice: "auto"
53+
}
54+
},
55+
etherscan: {
56+
apiKey: ETHERSCAN_API_KEY
57+
},
58+
paths: {
59+
sources: "./",
60+
tests: "./test",
61+
cache: "./cache",
62+
artifacts: "./artifacts"
63+
}
64+
};

contracts/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "trinity-contracts",
3+
"version": "1.0.0",
4+
"description": "$TRI Token Smart Contracts - Trinity Network",
5+
"scripts": {
6+
"compile": "hardhat compile",
7+
"test": "hardhat test",
8+
"deploy:local": "hardhat run scripts/deploy.js --network localhost",
9+
"deploy:sepolia": "hardhat run scripts/deploy.js --network sepolia",
10+
"deploy:mainnet": "hardhat run scripts/deploy.js --network mainnet",
11+
"verify": "hardhat verify --network mainnet",
12+
"pool:create": "hardhat run scripts/create-pool.js --network mainnet",
13+
"pool:add-liquidity": "hardhat run scripts/add-liquidity.js --network mainnet"
14+
},
15+
"dependencies": {
16+
"@openzeppelin/contracts": "^5.0.0",
17+
"@uniswap/v3-core": "^1.0.1",
18+
"@uniswap/v3-periphery": "^1.4.4",
19+
"@uniswap/v3-sdk": "^3.10.0",
20+
"ethers": "^6.9.0"
21+
},
22+
"devDependencies": {
23+
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
24+
"hardhat": "^2.19.0",
25+
"dotenv": "^16.3.1"
26+
},
27+
"keywords": ["trinity", "tri", "defi", "uniswap", "ternary", "ai"],
28+
"author": "@gHashTag",
29+
"license": "MIT"
30+
}

0 commit comments

Comments
 (0)