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:
@@ -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