chore: update DBIS contracts and integrate EIP-712 helper
- Updated DBIS_ConversionRouter and DBIS_SettlementRouter to utilize IDBIS_EIP712Helper for EIP-712 hashing and signature recovery, improving stack depth management. - Refactored minting logic in DBIS_GRU_MintController to streamline recipient processing. - Enhanced BUILD_NOTES.md with updated build instructions and test coverage details. - Added new functions in DBIS_SignerRegistry for duplicate signer checks and active signer validation. - Introduced a new submodule, DBIS_EIP712Helper, to encapsulate EIP-712 related functionalities. Made-with: Cursor
This commit is contained in:
@@ -6,6 +6,7 @@ import "../../contracts/dbis/DBIS_RootRegistry.sol";
|
||||
import "../../contracts/dbis/DBIS_ParticipantRegistry.sol";
|
||||
import "../../contracts/dbis/DBIS_SignerRegistry.sol";
|
||||
import "../../contracts/dbis/DBIS_GRU_MintController.sol";
|
||||
import "../../contracts/dbis/DBIS_EIP712Helper.sol";
|
||||
import "../../contracts/dbis/DBIS_SettlementRouter.sol";
|
||||
import "../../contracts/dbis/StablecoinReferenceRegistry.sol";
|
||||
import "../../contracts/dbis/DBIS_ConversionRouter.sol";
|
||||
@@ -27,9 +28,10 @@ contract DeployDBISRail is Script {
|
||||
DBIS_ParticipantRegistry participantReg = new DBIS_ParticipantRegistry(admin);
|
||||
DBIS_SignerRegistry signerReg = new DBIS_SignerRegistry(admin);
|
||||
DBIS_GRU_MintController mintController = new DBIS_GRU_MintController(admin, address(0));
|
||||
DBIS_SettlementRouter router = new DBIS_SettlementRouter(admin, address(root));
|
||||
address eip712LibAddr = address(new DBIS_EIP712Helper());
|
||||
DBIS_SettlementRouter router = new DBIS_SettlementRouter(admin, address(root), eip712LibAddr);
|
||||
StablecoinReferenceRegistry stableReg = new StablecoinReferenceRegistry(admin);
|
||||
DBIS_ConversionRouter conversionRouter = new DBIS_ConversionRouter(admin, address(root));
|
||||
DBIS_ConversionRouter conversionRouter = new DBIS_ConversionRouter(admin, address(root), eip712LibAddr);
|
||||
|
||||
root.setComponent(keccak256("ParticipantRegistry"), address(participantReg));
|
||||
root.setComponent(keccak256("SignerRegistry"), address(signerReg));
|
||||
@@ -42,6 +44,7 @@ contract DeployDBISRail is Script {
|
||||
|
||||
signerReg.setSwapQuorum(1e24, 2, 3);
|
||||
|
||||
console.log("DBIS_EIP712Helper", eip712LibAddr);
|
||||
console.log("DBIS_RootRegistry", address(root));
|
||||
console.log("DBIS_ParticipantRegistry", address(participantReg));
|
||||
console.log("DBIS_SignerRegistry", address(signerReg));
|
||||
|
||||
@@ -12,14 +12,22 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
* POOL_CUSDTCUSDC, POOL_CUSDTUSDT, POOL_CUSDCUSDC,
|
||||
* ADD_LIQUIDITY_BASE_AMOUNT, ADD_LIQUIDITY_QUOTE_AMOUNT (e.g. 1000000e6 for 1M units, 6 decimals).
|
||||
* Optional: ADD_LIQUIDITY_CUSDTCUSDC_BASE, ADD_LIQUIDITY_CUSDTCUSDC_QUOTE, etc. for per-pool amounts.
|
||||
* Optional: NEXT_NONCE — set to pending nonce (e.g. after mints) to avoid -32001 "Nonce too low" on broadcast.
|
||||
*/
|
||||
contract AddLiquidityPMMPoolsChain138 is Script {
|
||||
function run() external {
|
||||
uint256 pk = vm.envUint("PRIVATE_KEY");
|
||||
address deployer = vm.addr(pk);
|
||||
address integrationAddr = vm.envAddress("DODO_PMM_INTEGRATION");
|
||||
if (integrationAddr == address(0)) integrationAddr = vm.envAddress("DODO_PMM_INTEGRATION_ADDRESS");
|
||||
require(integrationAddr != address(0), "DODO_PMM_INTEGRATION not set");
|
||||
|
||||
// Use explicit nonce when set (e.g. after mints in same session) to avoid -32001 "Nonce too low"
|
||||
uint64 nextNonce = uint64(vm.envOr("NEXT_NONCE", uint256(0)));
|
||||
if (nextNonce > 0) {
|
||||
vm.setNonce(deployer, nextNonce);
|
||||
}
|
||||
|
||||
address poolCusdtCusdc = vm.envOr("POOL_CUSDTCUSDC", address(0));
|
||||
address poolCusdtUsdt = vm.envOr("POOL_CUSDTUSDT", address(0));
|
||||
address poolCusdcUsdc = vm.envOr("POOL_CUSDCUSDC", address(0));
|
||||
@@ -33,6 +41,13 @@ 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".
|
||||
bool skipOfficialPools = block.chainid == 138 && (
|
||||
!_isContract(usdt) || !_isContract(usdc)
|
||||
);
|
||||
|
||||
vm.startBroadcast(pk);
|
||||
|
||||
if (poolCusdtCusdc != address(0) && (defaultBase > 0 || defaultQuote > 0)) {
|
||||
@@ -43,7 +58,7 @@ contract AddLiquidityPMMPoolsChain138 is Script {
|
||||
console.log("Added liquidity to cUSDT/cUSDC pool:", poolCusdtCusdc);
|
||||
}
|
||||
}
|
||||
if (poolCusdtUsdt != address(0) && (defaultBase > 0 || defaultQuote > 0)) {
|
||||
if (!skipOfficialPools && poolCusdtUsdt != address(0) && (defaultBase > 0 || defaultQuote > 0)) {
|
||||
uint256 b = vm.envOr("ADD_LIQUIDITY_CUSDTUSDT_BASE", defaultBase);
|
||||
uint256 q = vm.envOr("ADD_LIQUIDITY_CUSDTUSDT_QUOTE", defaultQuote);
|
||||
if (b > 0 && q > 0) {
|
||||
@@ -51,7 +66,7 @@ contract AddLiquidityPMMPoolsChain138 is Script {
|
||||
console.log("Added liquidity to cUSDT/USDT pool:", poolCusdtUsdt);
|
||||
}
|
||||
}
|
||||
if (poolCusdcUsdc != address(0) && (defaultBase > 0 || defaultQuote > 0)) {
|
||||
if (!skipOfficialPools && poolCusdcUsdc != address(0) && (defaultBase > 0 || defaultQuote > 0)) {
|
||||
uint256 b = vm.envOr("ADD_LIQUIDITY_CUSDCUSDC_BASE", defaultBase);
|
||||
uint256 q = vm.envOr("ADD_LIQUIDITY_CUSDCUSDC_QUOTE", defaultQuote);
|
||||
if (b > 0 && q > 0) {
|
||||
@@ -63,6 +78,14 @@ contract AddLiquidityPMMPoolsChain138 is Script {
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
|
||||
function _isContract(address account) internal view returns (bool) {
|
||||
uint256 size;
|
||||
assembly {
|
||||
size := extcodesize(account)
|
||||
}
|
||||
return size > 0;
|
||||
}
|
||||
|
||||
function _approveAndAdd(
|
||||
DODOPMMIntegration integration,
|
||||
address baseToken,
|
||||
|
||||
Reference in New Issue
Block a user