feat: restore operator WIP — PMM JSON sync entrypoint, dotenv RPC trim + secrets, pool env alignment
- Resolve stash: merge load_deployment_env path with secure-secrets and CR/LF RPC strip - create-pmm-full-mesh-chain138.sh delegates to sync-chain138-pmm-pools-from-json.sh - env.additions.example: canonical PMM pool defaults (cUSDT/USDT per crosscheck) - Include Chain138 scripts, official mirror deploy scaffolding, and prior staged changes Made-with: Cursor
This commit is contained in:
@@ -41,9 +41,8 @@ contract AddLiquidityPMMPoolsChain138 is Script {
|
||||
address usdt = integration.officialUSDT();
|
||||
address usdc = integration.officialUSDC();
|
||||
|
||||
// On Chain 138, DODOPMMIntegration may have been deployed with mainnet official USDT/USDC
|
||||
// (0xdAC17F958D2ee523a2206206994597C13D831ec7, 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48).
|
||||
// Those addresses have no code on 138, so skip cUSDT/USDT and cUSDC/USDC to avoid "call to non-contract".
|
||||
// On Chain 138, cUSDT/USDT and cUSDC/USDC should point at live local mirror quote tokens.
|
||||
// If the configured quote-side addresses have no code on 138, skip those pools to avoid "call to non-contract".
|
||||
bool skipOfficialPools = block.chainid == 138 && (
|
||||
!_isContract(usdt) || !_isContract(usdc)
|
||||
);
|
||||
|
||||
89
script/dex/CreatePublicXAUPoolsChain138.s.sol
Normal file
89
script/dex/CreatePublicXAUPoolsChain138.s.sol
Normal file
@@ -0,0 +1,89 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {Script, console} from "forge-std/Script.sol";
|
||||
import {DODOPMMIntegration} from "../../contracts/dex/DODOPMMIntegration.sol";
|
||||
|
||||
/**
|
||||
* @title CreatePublicXAUPoolsChain138
|
||||
* @notice Create the public XAU-anchored pools on Chain 138 using the configured cXAU anchor token.
|
||||
* @dev Env:
|
||||
* - PRIVATE_KEY
|
||||
* - DODOPMM_INTEGRATION or DODOPMM_INTEGRATION_ADDRESS
|
||||
* - XAU_ADDRESS_138 or CXAUC_ADDRESS_138 or CXAUT_ADDRESS_138
|
||||
* Optional:
|
||||
* - COMPLIANT_USDT_ADDRESS, COMPLIANT_USDC_ADDRESS, cEURT_ADDRESS_138
|
||||
* - CREATE_CUSDT_XAU=1, CREATE_CUSDC_XAU=1, CREATE_CEURT_XAU=1
|
||||
*/
|
||||
contract CreatePublicXAUPoolsChain138 is Script {
|
||||
address internal constant CHAIN138_CUSDT = 0x93E66202A11B1772E55407B32B44e5Cd8eda7f22;
|
||||
address internal constant CHAIN138_CUSDC = 0xf22258f57794CC8E06237084b353Ab30fFfa640b;
|
||||
address internal constant CHAIN138_CEURT = 0xdf4b71c61E5912712C1Bdd451416B9aC26949d72;
|
||||
address internal constant CHAIN138_CXAUC = 0x290E52a8819A4fbD0714E517225429aA2B70EC6b;
|
||||
address internal constant CHAIN138_CXAUT = 0x94e408E26c6FD8F4ee00b54dF19082FDA07dC96E;
|
||||
|
||||
uint256 internal constant LP_FEE_BPS = 3;
|
||||
uint256 internal constant INITIAL_PRICE_1E18 = 1e18;
|
||||
uint256 internal constant K_50PCT = 0.5e18;
|
||||
bool internal constant USE_TWAP = true;
|
||||
|
||||
function run() external {
|
||||
uint256 pk = vm.envUint("PRIVATE_KEY");
|
||||
address integrationAddr = vm.envOr("DODOPMM_INTEGRATION", address(0));
|
||||
if (integrationAddr == address(0)) integrationAddr = vm.envOr("DODOPMM_INTEGRATION_ADDRESS", address(0));
|
||||
require(integrationAddr != address(0), "DODOPMM_INTEGRATION not set");
|
||||
|
||||
address xau = vm.envOr("XAU_ADDRESS_138", address(0));
|
||||
if (xau == address(0)) xau = vm.envOr("CXAUC_ADDRESS_138", address(0));
|
||||
if (xau == address(0)) xau = vm.envOr("CXAUT_ADDRESS_138", address(0));
|
||||
if (xau == address(0) && block.chainid == 138) xau = CHAIN138_CXAUC;
|
||||
require(xau != address(0), "XAU anchor not set");
|
||||
|
||||
address cUSDT = vm.envOr("COMPLIANT_USDT_ADDRESS", address(0));
|
||||
address cUSDC = vm.envOr("COMPLIANT_USDC_ADDRESS", address(0));
|
||||
address cEURT = vm.envOr("cEURT_ADDRESS_138", address(0));
|
||||
|
||||
if (cUSDT == address(0) && block.chainid == 138) cUSDT = CHAIN138_CUSDT;
|
||||
if (cUSDC == address(0) && block.chainid == 138) cUSDC = CHAIN138_CUSDC;
|
||||
if (cEURT == address(0) && block.chainid == 138) cEURT = CHAIN138_CEURT;
|
||||
|
||||
bool createCUSDT = vm.envOr("CREATE_CUSDT_XAU", true);
|
||||
bool createCUSDC = vm.envOr("CREATE_CUSDC_XAU", true);
|
||||
bool createCEURT = vm.envOr("CREATE_CEURT_XAU", true);
|
||||
|
||||
DODOPMMIntegration integration = DODOPMMIntegration(integrationAddr);
|
||||
|
||||
vm.startBroadcast(pk);
|
||||
|
||||
if (createCUSDT && cUSDT != address(0)) {
|
||||
_createIfMissing(integration, cUSDT, xau, "cUSDT/XAU");
|
||||
}
|
||||
if (createCUSDC && cUSDC != address(0)) {
|
||||
_createIfMissing(integration, cUSDC, xau, "cUSDC/XAU");
|
||||
}
|
||||
if (createCEURT && cEURT != address(0)) {
|
||||
_createIfMissing(integration, cEURT, xau, "cEURT/XAU");
|
||||
}
|
||||
|
||||
vm.stopBroadcast();
|
||||
|
||||
console.log("Public XAU pools checked against anchor:", xau == CHAIN138_CXAUC ? "cXAUC" : (xau == CHAIN138_CXAUT ? "cXAUT" : "custom"));
|
||||
console.log("Default Chain 138 XAU anchors:", vm.toString(CHAIN138_CXAUC), vm.toString(CHAIN138_CXAUT));
|
||||
}
|
||||
|
||||
function _createIfMissing(
|
||||
DODOPMMIntegration integration,
|
||||
address base,
|
||||
address quote,
|
||||
string memory label
|
||||
) internal {
|
||||
address existing = integration.pools(base, quote);
|
||||
if (existing != address(0)) {
|
||||
console.log(label, "already exists at", existing);
|
||||
return;
|
||||
}
|
||||
|
||||
address pool = integration.createPool(base, quote, LP_FEE_BPS, INITIAL_PRICE_1E18, K_50PCT, USE_TWAP);
|
||||
console.log(label, "created at", pool);
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,16 @@ contract DeployDODOPMMIntegration is Script {
|
||||
address compliantUSDT = vm.envOr("COMPLIANT_USDT_ADDRESS", address(0));
|
||||
address compliantUSDC = vm.envOr("COMPLIANT_USDC_ADDRESS", address(0));
|
||||
|
||||
if (dodoVendingMachine == address(0) || compliantUSDT == address(0) || compliantUSDC == address(0)) {
|
||||
console.log("Skipping DODO PMM deploy: set DODO_VENDING_MACHINE_ADDRESS, COMPLIANT_USDT_ADDRESS, COMPLIANT_USDC_ADDRESS in .env");
|
||||
if (
|
||||
dodoVendingMachine == address(0) ||
|
||||
officialUSDT == address(0) ||
|
||||
officialUSDC == address(0) ||
|
||||
compliantUSDT == address(0) ||
|
||||
compliantUSDC == address(0)
|
||||
) {
|
||||
console.log(
|
||||
"Skipping DODO PMM deploy: set DODO_VENDING_MACHINE_ADDRESS, OFFICIAL_USDT_ADDRESS, OFFICIAL_USDC_ADDRESS, COMPLIANT_USDT_ADDRESS, COMPLIANT_USDC_ADDRESS in .env"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,4 +72,3 @@ contract DeployDODOPMMIntegration is Script {
|
||||
console.log("3. Configure pool parameters (lpFeeRate, k, initialPrice)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import {DODOPMMIntegration} from "../../contracts/dex/DODOPMMIntegration.sol";
|
||||
* Deployer must have POOL_MANAGER_ROLE on DODOPMMIntegration to create pools.
|
||||
*/
|
||||
contract DeployPrivatePoolRegistryAndPools is Script {
|
||||
address internal constant CHAIN138_CXAUC = 0x290E52a8819A4fbD0714E517225429aA2B70EC6b;
|
||||
address internal constant CHAIN138_CXAUT = 0x94e408E26c6FD8F4ee00b54dF19082FDA07dC96E;
|
||||
uint256 constant LP_FEE_BPS = 3;
|
||||
uint256 constant INITIAL_PRICE_1E18 = 1e18;
|
||||
uint256 constant K_50PCT = 0.5e18;
|
||||
@@ -29,35 +31,37 @@ contract DeployPrivatePoolRegistryAndPools is Script {
|
||||
console.log("PrivatePoolRegistry deployed at:", vm.toString(address(registry)));
|
||||
|
||||
address integrationAddr = vm.envOr("DODOPMM_INTEGRATION_ADDRESS", address(0));
|
||||
if (integrationAddr == address(0)) integrationAddr = vm.envOr("DODO_PMM_INTEGRATION_ADDRESS", address(0));
|
||||
if (integrationAddr == address(0)) integrationAddr = vm.envOr("DODOPMM_INTEGRATION", address(0));
|
||||
if (integrationAddr == address(0)) integrationAddr = vm.envOr("DODO_PMM_INTEGRATION", address(0));
|
||||
address xau = vm.envOr("XAU_ADDRESS_138", address(0));
|
||||
if (xau == address(0)) xau = vm.envOr("CXAUC_ADDRESS_138", address(0));
|
||||
if (xau == address(0)) xau = vm.envOr("CXAUT_ADDRESS_138", address(0));
|
||||
if (xau == address(0) && block.chainid == 138) xau = CHAIN138_CXAUC;
|
||||
|
||||
if (integrationAddr != address(0) && xau != address(0)) {
|
||||
address cUSDT = vm.envOr("COMPLIANT_USDT_ADDRESS", address(0));
|
||||
address cUSDC = vm.envOr("COMPLIANT_USDC_ADDRESS", address(0));
|
||||
address cEURT = vm.envOr("cEURT_ADDRESS_138", address(0));
|
||||
if (cUSDT == address(0) && block.chainid == 138) cUSDT = 0x93E66202A11B1772E55407B32B44e5Cd8eda7f22;
|
||||
if (cUSDC == address(0) && block.chainid == 138) cUSDC = 0xf22258f57794CC8E06237084b353Ab30fFfa640b;
|
||||
if (cEURT == address(0) && block.chainid == 138) cEURT = 0xdf4b71c61E5912712C1Bdd451416B9aC26949d72;
|
||||
|
||||
DODOPMMIntegration integration = DODOPMMIntegration(integrationAddr);
|
||||
|
||||
if (cUSDT != address(0)) {
|
||||
try integration.createPool(cUSDT, xau, LP_FEE_BPS, INITIAL_PRICE_1E18, K_50PCT, USE_TWAP) returns (address pool) {
|
||||
registry.register(cUSDT, xau, pool);
|
||||
console.log("Created and registered cUSDT/XAU pool:", vm.toString(pool));
|
||||
} catch {}
|
||||
_ensureRegistered(registry, integration, cUSDT, xau, "cUSDT/XAU");
|
||||
}
|
||||
if (cUSDC != address(0)) {
|
||||
try integration.createPool(cUSDC, xau, LP_FEE_BPS, INITIAL_PRICE_1E18, K_50PCT, USE_TWAP) returns (address pool) {
|
||||
registry.register(cUSDC, xau, pool);
|
||||
console.log("Created and registered cUSDC/XAU pool:", vm.toString(pool));
|
||||
} catch {}
|
||||
_ensureRegistered(registry, integration, cUSDC, xau, "cUSDC/XAU");
|
||||
}
|
||||
if (cEURT != address(0)) {
|
||||
try integration.createPool(cEURT, xau, LP_FEE_BPS, INITIAL_PRICE_1E18, K_50PCT, USE_TWAP) returns (address pool) {
|
||||
registry.register(cEURT, xau, pool);
|
||||
console.log("Created and registered cEURT/XAU pool:", vm.toString(pool));
|
||||
} catch {}
|
||||
_ensureRegistered(registry, integration, cEURT, xau, "cEURT/XAU");
|
||||
}
|
||||
} else {
|
||||
console.log("Skipping pool creation (set DODOPMM_INTEGRATION_ADDRESS and XAU_ADDRESS_138 to create XAU-anchored pools)");
|
||||
console.log(
|
||||
"Skipping pool creation (set DODOPMM_INTEGRATION_ADDRESS and XAU_ADDRESS_138/CXAUC_ADDRESS_138/CXAUT_ADDRESS_138 to create XAU-anchored pools)"
|
||||
);
|
||||
}
|
||||
|
||||
vm.stopBroadcast();
|
||||
@@ -65,5 +69,30 @@ contract DeployPrivatePoolRegistryAndPools is Script {
|
||||
console.log("\n=== Deployment Summary ===");
|
||||
console.log("PrivatePoolRegistry:", vm.toString(address(registry)));
|
||||
console.log("Admin:", vm.toString(admin));
|
||||
console.log("Default XAU anchor on Chain 138:", vm.toString(CHAIN138_CXAUC));
|
||||
console.log("Alternate XAU anchor on Chain 138:", vm.toString(CHAIN138_CXAUT));
|
||||
}
|
||||
|
||||
function _ensureRegistered(
|
||||
PrivatePoolRegistry registry,
|
||||
DODOPMMIntegration integration,
|
||||
address base,
|
||||
address quote,
|
||||
string memory label
|
||||
) internal {
|
||||
address pool = integration.pools(base, quote);
|
||||
if (pool == address(0)) {
|
||||
pool = integration.createPool(base, quote, LP_FEE_BPS, INITIAL_PRICE_1E18, K_50PCT, USE_TWAP);
|
||||
console.log("Created", label, "pool:", vm.toString(pool));
|
||||
} else {
|
||||
console.log(label, "pool already exists:", vm.toString(pool));
|
||||
}
|
||||
|
||||
if (registry.getPrivatePool(base, quote) == address(0)) {
|
||||
registry.register(base, quote, pool);
|
||||
console.log("Registered", label, "pool:", vm.toString(pool));
|
||||
} else {
|
||||
console.log(label, "already registered:", vm.toString(registry.getPrivatePool(base, quote)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user