added web-app and landing
This commit is contained in:
parent
af031877a5
commit
769fa105b8
198 changed files with 22132 additions and 10 deletions
18
onchain/deployments-local.json
Normal file
18
onchain/deployments-local.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"chainId": 31337,
|
||||
"network": "local",
|
||||
"deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||
"deploymentDate": "2024-12-07",
|
||||
"contracts": {
|
||||
"Kraiken": "0xB58F7a0D856eed18B9f19072dD0843bf03E4eB24",
|
||||
"Stake": "0xa568b723199980B98E1BF765aB2A531C70a5edB3",
|
||||
"Pool": "0x8F02719c2840428b27CD94E2b01e0aE69D796523",
|
||||
"LiquidityManager": "0xbfE20DAb7BefF64237E2162D86F42Bfa228903B5",
|
||||
"Optimizer": "0x22132dA9e3181850A692d8c36e117BdF30cA911E"
|
||||
},
|
||||
"infrastructure": {
|
||||
"weth": "0x4200000000000000000000000000000000000006",
|
||||
"factory": "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",
|
||||
"feeDest": "0xf6a3eef9088A255c32b6aD2025f83E57291D9011"
|
||||
}
|
||||
}
|
||||
50
onchain/package-lock.json
generated
Normal file
50
onchain/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "onchain",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@uniswap/universal-router": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@openzeppelin/contracts": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-5.0.2.tgz",
|
||||
"integrity": "sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@uniswap/universal-router": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@uniswap/universal-router/-/universal-router-2.0.0.tgz",
|
||||
"integrity": "sha512-6V21kuf547hE1gLfLQ89gv41DMSJY1ZZKer/k7CBagNPJ0oDnUyme+qQPtdoWknyUgSKd1M6sDm/WpocjVmPlA==",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "5.0.2",
|
||||
"@uniswap/v2-core": "1.0.1",
|
||||
"@uniswap/v3-core": "1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@uniswap/v2-core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@uniswap/v2-core/-/v2-core-1.0.1.tgz",
|
||||
"integrity": "sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q==",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@uniswap/v3-core": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@uniswap/v3-core/-/v3-core-1.0.0.tgz",
|
||||
"integrity": "sha512-kSC4djMGKMHj7sLMYVnn61k9nu+lHjMIxgg9CDQT+s2QYLoA56GbSK9Oxr+qJXzzygbkrmuY6cwgP6cW2JXPFA==",
|
||||
"license": "BUSL-1.1",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
onchain/package.json
Normal file
5
onchain/package.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@uniswap/universal-router": "^2.0.0"
|
||||
}
|
||||
}
|
||||
118
onchain/script/DeployBase.sol
Normal file
118
onchain/script/DeployBase.sol
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "forge-std/Script.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import {LiquidityManager} from "../src/LiquidityManager.sol";
|
||||
import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
|
||||
uint24 constant FEE = uint24(10_000);
|
||||
|
||||
contract DeployBase is Script {
|
||||
using UniswapHelpers for IUniswapV3Pool;
|
||||
|
||||
bool public token0isWeth;
|
||||
address public feeDest;
|
||||
address public weth;
|
||||
address public v3Factory;
|
||||
address public optimizer;
|
||||
|
||||
// Deployed contracts
|
||||
Kraiken public kraiken;
|
||||
Stake public stake;
|
||||
LiquidityManager public liquidityManager;
|
||||
IUniswapV3Pool public pool;
|
||||
|
||||
function run() public {
|
||||
string memory seedPhrase = vm.readFile(".secret");
|
||||
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
||||
vm.startBroadcast(privateKey);
|
||||
address sender = vm.addr(privateKey);
|
||||
|
||||
console.log("Deploying from:", sender);
|
||||
|
||||
// Deploy Kraiken token
|
||||
kraiken = new Kraiken("Kraiken", "KRK");
|
||||
console.log("Kraiken deployed at:", address(kraiken));
|
||||
|
||||
// Determine token ordering
|
||||
token0isWeth = address(weth) < address(kraiken);
|
||||
console.log("token0isWeth:", token0isWeth);
|
||||
|
||||
// Deploy Stake contract
|
||||
stake = new Stake(address(kraiken), feeDest);
|
||||
console.log("Stake deployed at:", address(stake));
|
||||
|
||||
// Set staking pool in Kraiken
|
||||
kraiken.setStakingPool(address(stake));
|
||||
|
||||
// Get or create Uniswap V3 pool
|
||||
IUniswapV3Factory factory = IUniswapV3Factory(v3Factory);
|
||||
address liquidityPool = factory.getPool(weth, address(kraiken), FEE);
|
||||
if (liquidityPool == address(0)) {
|
||||
liquidityPool = factory.createPool(weth, address(kraiken), FEE);
|
||||
console.log("Uniswap pool created at:", liquidityPool);
|
||||
} else {
|
||||
console.log("Using existing pool at:", liquidityPool);
|
||||
}
|
||||
pool = IUniswapV3Pool(liquidityPool);
|
||||
|
||||
// Initialize pool at 1 cent price if not already initialized
|
||||
try pool.slot0() returns (uint160, int24, uint16, uint16, uint16, uint8, bool) {
|
||||
console.log("Pool already initialized");
|
||||
} catch {
|
||||
pool.initializePoolFor1Cent(token0isWeth);
|
||||
console.log("Pool initialized");
|
||||
}
|
||||
|
||||
// Deploy Optimizer (if not already deployed)
|
||||
address optimizerAddress;
|
||||
if (optimizer == address(0)) {
|
||||
Optimizer optimizerImpl = new Optimizer();
|
||||
bytes memory params = abi.encodeWithSignature(
|
||||
"initialize(address,address)",
|
||||
address(kraiken),
|
||||
address(stake)
|
||||
);
|
||||
ERC1967Proxy proxy = new ERC1967Proxy(address(optimizerImpl), params);
|
||||
optimizerAddress = address(proxy);
|
||||
console.log("Optimizer deployed at:", optimizerAddress);
|
||||
} else {
|
||||
optimizerAddress = optimizer;
|
||||
console.log("Using existing optimizer at:", optimizerAddress);
|
||||
}
|
||||
|
||||
// Deploy LiquidityManager
|
||||
liquidityManager = new LiquidityManager(
|
||||
v3Factory,
|
||||
weth,
|
||||
address(kraiken),
|
||||
optimizerAddress
|
||||
);
|
||||
console.log("LiquidityManager deployed at:", address(liquidityManager));
|
||||
|
||||
// Set fee destination
|
||||
liquidityManager.setFeeDestination(feeDest);
|
||||
|
||||
// Set liquidity manager in Kraiken
|
||||
kraiken.setLiquidityManager(address(liquidityManager));
|
||||
|
||||
// Note: Fund liquidity manager manually after deployment
|
||||
console.log("Remember to fund LiquidityManager with ETH");
|
||||
|
||||
console.log("\n=== Deployment Complete ===");
|
||||
console.log("Kraiken:", address(kraiken));
|
||||
console.log("Stake:", address(stake));
|
||||
console.log("Pool:", address(pool));
|
||||
console.log("LiquidityManager:", address(liquidityManager));
|
||||
console.log("Optimizer:", optimizerAddress);
|
||||
console.log("\nNext step: Wait a few minutes then call liquidityManager.recenter()");
|
||||
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
}
|
||||
24
onchain/script/DeployBaseMainnet.sol
Normal file
24
onchain/script/DeployBaseMainnet.sol
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {DeployBase} from "./DeployBase.sol";
|
||||
|
||||
/**
|
||||
* @title DeployBaseMainnet
|
||||
* @notice Deployment script for Base mainnet
|
||||
* @dev Run with: forge script script/DeployBaseMainnet.sol --rpc-url $BASE_RPC --broadcast --verify
|
||||
* @dev IMPORTANT: Review all parameters carefully before mainnet deployment
|
||||
*/
|
||||
contract DeployBaseMainnet is DeployBase {
|
||||
constructor() {
|
||||
// Base mainnet configuration
|
||||
// TODO: Update fee destination for mainnet
|
||||
feeDest = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011; // UPDATE THIS FOR MAINNET
|
||||
|
||||
weth = 0x4200000000000000000000000000000000000006; // WETH on Base mainnet
|
||||
v3Factory = 0x33128a8fC17869897dcE68Ed026d694621f6FDfD; // Uniswap V3 Factory on Base mainnet
|
||||
|
||||
// Leave as address(0) to deploy new optimizer
|
||||
optimizer = address(0);
|
||||
}
|
||||
}
|
||||
22
onchain/script/DeployBaseSepolia.sol
Normal file
22
onchain/script/DeployBaseSepolia.sol
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {DeployBase} from "./DeployBase.sol";
|
||||
|
||||
/**
|
||||
* @title DeployBaseSepolia
|
||||
* @notice Deployment script for Base Sepolia testnet
|
||||
* @dev Run with: forge script script/DeployBaseSepolia.sol --rpc-url $BASE_SEPOLIA_RPC --broadcast --verify
|
||||
*/
|
||||
contract DeployBaseSepolia is DeployBase {
|
||||
constructor() {
|
||||
// Base Sepolia testnet configuration
|
||||
feeDest = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011; // Fee destination address
|
||||
weth = 0x4200000000000000000000000000000000000006; // WETH on Base Sepolia
|
||||
v3Factory = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24; // Uniswap V3 Factory on Base Sepolia
|
||||
|
||||
// Uncomment if reusing existing optimizer (for upgrades)
|
||||
// optimizer = 0xFCFa3b066981027516121bd27a9B1cBb9C00c5Fd;
|
||||
optimizer = address(0); // Deploy new optimizer
|
||||
}
|
||||
}
|
||||
133
onchain/script/DeployLocal.sol
Normal file
133
onchain/script/DeployLocal.sol
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "forge-std/Script.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import {LiquidityManager} from "../src/LiquidityManager.sol";
|
||||
import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
|
||||
/**
|
||||
* @title DeployLocal
|
||||
* @notice Deployment script for local Anvil fork
|
||||
* @dev Run with: forge script script/DeployLocal.sol --rpc-url http://localhost:8545 --broadcast
|
||||
*/
|
||||
contract DeployLocal is Script {
|
||||
using UniswapHelpers for IUniswapV3Pool;
|
||||
|
||||
uint24 constant FEE = uint24(10_000);
|
||||
|
||||
// Configuration
|
||||
address constant feeDest = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011;
|
||||
address constant weth = 0x4200000000000000000000000000000000000006;
|
||||
address constant v3Factory = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24;
|
||||
|
||||
// Deployed contracts
|
||||
Kraiken public kraiken;
|
||||
Stake public stake;
|
||||
LiquidityManager public liquidityManager;
|
||||
IUniswapV3Pool public pool;
|
||||
bool public token0isWeth;
|
||||
|
||||
function run() public {
|
||||
// Use local mnemonic file for consistent deployment
|
||||
string memory seedPhrase = vm.readFile(".secret.local");
|
||||
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
||||
vm.startBroadcast(privateKey);
|
||||
address sender = vm.addr(privateKey);
|
||||
|
||||
console.log("\n=== Starting Local Deployment ===");
|
||||
console.log("Deployer:", sender);
|
||||
console.log("Using mnemonic from .secret.local");
|
||||
console.log("Chain ID: 31337 (Local Anvil)");
|
||||
|
||||
// Deploy Kraiken token
|
||||
kraiken = new Kraiken("Kraiken", "KRK");
|
||||
console.log("\n[1/6] Kraiken deployed:", address(kraiken));
|
||||
|
||||
// Determine token ordering
|
||||
token0isWeth = address(weth) < address(kraiken);
|
||||
console.log(" Token ordering - WETH is token0:", token0isWeth);
|
||||
|
||||
// Deploy Stake contract
|
||||
stake = new Stake(address(kraiken), feeDest);
|
||||
console.log("\n[2/6] Stake deployed:", address(stake));
|
||||
|
||||
// Set staking pool in Kraiken
|
||||
kraiken.setStakingPool(address(stake));
|
||||
console.log(" Staking pool set in Kraiken");
|
||||
|
||||
// Get or create Uniswap V3 pool
|
||||
IUniswapV3Factory factory = IUniswapV3Factory(v3Factory);
|
||||
address liquidityPool = factory.getPool(weth, address(kraiken), FEE);
|
||||
if (liquidityPool == address(0)) {
|
||||
liquidityPool = factory.createPool(weth, address(kraiken), FEE);
|
||||
console.log("\n[3/6] Uniswap pool created:", liquidityPool);
|
||||
} else {
|
||||
console.log("\n[3/6] Using existing pool:", liquidityPool);
|
||||
}
|
||||
pool = IUniswapV3Pool(liquidityPool);
|
||||
|
||||
// Initialize pool at 1 cent price if not already initialized
|
||||
try pool.slot0() returns (uint160 sqrtPriceX96, int24, uint16, uint16, uint16, uint8, bool) {
|
||||
if (sqrtPriceX96 == 0) {
|
||||
pool.initializePoolFor1Cent(token0isWeth);
|
||||
console.log(" Pool initialized at 1 cent price");
|
||||
} else {
|
||||
console.log(" Pool already initialized");
|
||||
}
|
||||
} catch {
|
||||
pool.initializePoolFor1Cent(token0isWeth);
|
||||
console.log(" Pool initialized at 1 cent price");
|
||||
}
|
||||
|
||||
// Deploy Optimizer
|
||||
Optimizer optimizerImpl = new Optimizer();
|
||||
bytes memory params = abi.encodeWithSignature(
|
||||
"initialize(address,address)",
|
||||
address(kraiken),
|
||||
address(stake)
|
||||
);
|
||||
ERC1967Proxy proxy = new ERC1967Proxy(address(optimizerImpl), params);
|
||||
address optimizerAddress = address(proxy);
|
||||
console.log("\n[4/6] Optimizer deployed:", optimizerAddress);
|
||||
|
||||
// Deploy LiquidityManager
|
||||
liquidityManager = new LiquidityManager(
|
||||
v3Factory,
|
||||
weth,
|
||||
address(kraiken),
|
||||
optimizerAddress
|
||||
);
|
||||
console.log("\n[5/6] LiquidityManager deployed:", address(liquidityManager));
|
||||
|
||||
// Configure contracts
|
||||
liquidityManager.setFeeDestination(feeDest);
|
||||
console.log(" Fee destination set");
|
||||
|
||||
kraiken.setLiquidityManager(address(liquidityManager));
|
||||
console.log(" LiquidityManager set in Kraiken");
|
||||
|
||||
console.log("\n[6/6] Configuration complete");
|
||||
|
||||
// Print deployment summary
|
||||
console.log("\n=== Deployment Summary ===");
|
||||
console.log("Kraiken (KRK):", address(kraiken));
|
||||
console.log("Stake:", address(stake));
|
||||
console.log("Pool:", address(pool));
|
||||
console.log("LiquidityManager:", address(liquidityManager));
|
||||
console.log("Optimizer:", optimizerAddress);
|
||||
|
||||
console.log("\n=== Next Steps ===");
|
||||
console.log("1. Fund LiquidityManager with ETH:");
|
||||
console.log(" cast send", address(liquidityManager), "--value 0.1ether");
|
||||
console.log("2. Call recenter to initialize positions:");
|
||||
console.log(" cast send", address(liquidityManager), '"recenter()"');
|
||||
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue