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:
@@ -110,6 +110,12 @@ contract DODOPMMIntegration is AccessControl, ReentrancyGuard {
|
||||
);
|
||||
event PoolRemoved(address indexed pool);
|
||||
event ReserveSystemSet(address indexed reserveSystem);
|
||||
event PoolImported(
|
||||
address indexed pool,
|
||||
address indexed baseToken,
|
||||
address indexed quoteToken,
|
||||
address importer
|
||||
);
|
||||
|
||||
constructor(
|
||||
address admin,
|
||||
@@ -164,22 +170,7 @@ contract DODOPMMIntegration is AccessControl, ReentrancyGuard {
|
||||
isOpenTWAP // Enable TWAP
|
||||
);
|
||||
|
||||
// Register pool
|
||||
pools[compliantUSDT][officialUSDT] = pool;
|
||||
pools[officialUSDT][compliantUSDT] = pool;
|
||||
isRegisteredPool[pool] = true;
|
||||
allPools.push(pool);
|
||||
|
||||
poolConfigs[pool] = PoolConfig({
|
||||
pool: pool,
|
||||
baseToken: compliantUSDT,
|
||||
quoteToken: officialUSDT,
|
||||
lpFeeRate: lpFeeRate,
|
||||
i: initialPrice,
|
||||
k: k,
|
||||
isOpenTWAP: isOpenTWAP,
|
||||
createdAt: block.timestamp
|
||||
});
|
||||
_recordPool(pool, compliantUSDT, officialUSDT, lpFeeRate, initialPrice, k, isOpenTWAP);
|
||||
|
||||
emit PoolCreated(pool, compliantUSDT, officialUSDT, msg.sender);
|
||||
}
|
||||
@@ -208,21 +199,7 @@ contract DODOPMMIntegration is AccessControl, ReentrancyGuard {
|
||||
isOpenTWAP
|
||||
);
|
||||
|
||||
pools[compliantUSDC][officialUSDC] = pool;
|
||||
pools[officialUSDC][compliantUSDC] = pool;
|
||||
isRegisteredPool[pool] = true;
|
||||
allPools.push(pool);
|
||||
|
||||
poolConfigs[pool] = PoolConfig({
|
||||
pool: pool,
|
||||
baseToken: compliantUSDC,
|
||||
quoteToken: officialUSDC,
|
||||
lpFeeRate: lpFeeRate,
|
||||
i: initialPrice,
|
||||
k: k,
|
||||
isOpenTWAP: isOpenTWAP,
|
||||
createdAt: block.timestamp
|
||||
});
|
||||
_recordPool(pool, compliantUSDC, officialUSDC, lpFeeRate, initialPrice, k, isOpenTWAP);
|
||||
|
||||
emit PoolCreated(pool, compliantUSDC, officialUSDC, msg.sender);
|
||||
}
|
||||
@@ -251,21 +228,7 @@ contract DODOPMMIntegration is AccessControl, ReentrancyGuard {
|
||||
isOpenTWAP
|
||||
);
|
||||
|
||||
pools[compliantUSDT][compliantUSDC] = pool;
|
||||
pools[compliantUSDC][compliantUSDT] = pool;
|
||||
isRegisteredPool[pool] = true;
|
||||
allPools.push(pool);
|
||||
|
||||
poolConfigs[pool] = PoolConfig({
|
||||
pool: pool,
|
||||
baseToken: compliantUSDT,
|
||||
quoteToken: compliantUSDC,
|
||||
lpFeeRate: lpFeeRate,
|
||||
i: initialPrice,
|
||||
k: k,
|
||||
isOpenTWAP: isOpenTWAP,
|
||||
createdAt: block.timestamp
|
||||
});
|
||||
_recordPool(pool, compliantUSDT, compliantUSDC, lpFeeRate, initialPrice, k, isOpenTWAP);
|
||||
|
||||
emit PoolCreated(pool, compliantUSDT, compliantUSDC, msg.sender);
|
||||
}
|
||||
@@ -301,25 +264,46 @@ contract DODOPMMIntegration is AccessControl, ReentrancyGuard {
|
||||
isOpenTWAP
|
||||
);
|
||||
|
||||
pools[baseToken][quoteToken] = pool;
|
||||
pools[quoteToken][baseToken] = pool;
|
||||
isRegisteredPool[pool] = true;
|
||||
allPools.push(pool);
|
||||
|
||||
poolConfigs[pool] = PoolConfig({
|
||||
pool: pool,
|
||||
baseToken: baseToken,
|
||||
quoteToken: quoteToken,
|
||||
lpFeeRate: lpFeeRate,
|
||||
i: initialPrice,
|
||||
k: k,
|
||||
isOpenTWAP: isOpenTWAP,
|
||||
createdAt: block.timestamp
|
||||
});
|
||||
_recordPool(pool, baseToken, quoteToken, lpFeeRate, initialPrice, k, isOpenTWAP);
|
||||
|
||||
emit PoolCreated(pool, baseToken, quoteToken, msg.sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Import an already-deployed DODO PMM pool into integration state.
|
||||
* @dev Use this when the pool exists at the DODO/provider layer but was not
|
||||
* recorded in the integration mappings or allPools inventory.
|
||||
*/
|
||||
function importExistingPool(
|
||||
address pool,
|
||||
address baseToken,
|
||||
address quoteToken,
|
||||
uint256 lpFeeRate,
|
||||
uint256 initialPrice,
|
||||
uint256 k,
|
||||
bool isOpenTWAP
|
||||
) external onlyRole(POOL_MANAGER_ROLE) {
|
||||
require(pool != address(0), "DODOPMMIntegration: zero pool");
|
||||
require(baseToken != address(0), "DODOPMMIntegration: zero base");
|
||||
require(quoteToken != address(0), "DODOPMMIntegration: zero quote");
|
||||
require(baseToken != quoteToken, "DODOPMMIntegration: same token");
|
||||
require(pools[baseToken][quoteToken] == address(0), "DODOPMMIntegration: pair already recorded");
|
||||
require(!isRegisteredPool[pool], "DODOPMMIntegration: pool already registered");
|
||||
|
||||
address actualBase = IDODOPMMPool(pool)._BASE_TOKEN_();
|
||||
address actualQuote = IDODOPMMPool(pool)._QUOTE_TOKEN_();
|
||||
bool matchesForward = actualBase == baseToken && actualQuote == quoteToken;
|
||||
bool matchesReverse = actualBase == quoteToken && actualQuote == baseToken;
|
||||
require(matchesForward || matchesReverse, "DODOPMMIntegration: pool token mismatch");
|
||||
|
||||
if (matchesReverse) {
|
||||
(baseToken, quoteToken) = (quoteToken, baseToken);
|
||||
}
|
||||
|
||||
_recordPool(pool, baseToken, quoteToken, lpFeeRate, initialPrice, k, isOpenTWAP);
|
||||
emit PoolImported(pool, baseToken, quoteToken, msg.sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Add liquidity to a DODO PMM pool
|
||||
* @param pool Pool address
|
||||
@@ -595,5 +579,30 @@ contract DODOPMMIntegration is AccessControl, ReentrancyGuard {
|
||||
|
||||
emit PoolRemoved(pool);
|
||||
}
|
||||
}
|
||||
|
||||
function _recordPool(
|
||||
address pool,
|
||||
address baseToken,
|
||||
address quoteToken,
|
||||
uint256 lpFeeRate,
|
||||
uint256 initialPrice,
|
||||
uint256 k,
|
||||
bool isOpenTWAP
|
||||
) internal {
|
||||
pools[baseToken][quoteToken] = pool;
|
||||
pools[quoteToken][baseToken] = pool;
|
||||
isRegisteredPool[pool] = true;
|
||||
allPools.push(pool);
|
||||
|
||||
poolConfigs[pool] = PoolConfig({
|
||||
pool: pool,
|
||||
baseToken: baseToken,
|
||||
quoteToken: quoteToken,
|
||||
lpFeeRate: lpFeeRate,
|
||||
i: initialPrice,
|
||||
k: k,
|
||||
isOpenTWAP: isOpenTWAP,
|
||||
createdAt: block.timestamp
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user