diff --git a/.openzeppelin/unknown-421614.json b/.openzeppelin/unknown-421614.json index 0e2466d..ac185f6 100644 --- a/.openzeppelin/unknown-421614.json +++ b/.openzeppelin/unknown-421614.json @@ -8581,6 +8581,958 @@ }, "namespaces": {} } + }, + "04a237c50c8440073e98b23ad568cbbd4edf1b159ab18d1f88ee087836966377": { + "address": "0xc74D946eBda11E7d9A22AADa8508E824DaBf79be", + "txHash": "0xc6fdb002f9334849b36774a5f33a8e9b01713f14d04f8b0f5c3a4312852b2bee", + "layout": { + "solcVersion": "0.8.18", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "__gap", + "offset": 0, + "slot": "51", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC165Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:41" + }, + { + "label": "_roles", + "offset": 0, + "slot": "101", + "type": "t_mapping(t_bytes32,t_struct(RoleData)747_storage)", + "contract": "AccessControlUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:62" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "AccessControlUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:260" + }, + { + "label": "_pendingDefaultAdmin", + "offset": 0, + "slot": "151", + "type": "t_address", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:43" + }, + { + "label": "_pendingDefaultAdminSchedule", + "offset": 20, + "slot": "151", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:44" + }, + { + "label": "_currentDelay", + "offset": 26, + "slot": "151", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:46" + }, + { + "label": "_currentDefaultAdmin", + "offset": 0, + "slot": "152", + "type": "t_address", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:47" + }, + { + "label": "_pendingDelay", + "offset": 20, + "slot": "152", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:50" + }, + { + "label": "_pendingDelaySchedule", + "offset": 26, + "slot": "152", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:51" + }, + { + "label": "__gap", + "offset": 0, + "slot": "153", + "type": "t_array(t_uint256)48_storage", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:394" + }, + { + "label": "_paused", + "offset": 0, + "slot": "201", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:116" + }, + { + "label": "_index", + "offset": 0, + "slot": "251", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:47" + }, + { + "label": "dlcs", + "offset": 0, + "slot": "252", + "type": "t_mapping(t_uint256,t_struct(DLC)7626_storage)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:48" + }, + { + "label": "dlcIDsByUUID", + "offset": 0, + "slot": "253", + "type": "t_mapping(t_bytes32,t_uint256)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:49" + }, + { + "label": "_minimumThreshold", + "offset": 0, + "slot": "254", + "type": "t_uint16", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:51" + }, + { + "label": "_threshold", + "offset": 2, + "slot": "254", + "type": "t_uint16", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:52" + }, + { + "label": "_signerCount", + "offset": 4, + "slot": "254", + "type": "t_uint16", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:53" + }, + { + "label": "tssCommitment", + "offset": 0, + "slot": "255", + "type": "t_bytes32", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:54" + }, + { + "label": "attestorGroupPubKey", + "offset": 0, + "slot": "256", + "type": "t_string_storage", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:55" + }, + { + "label": "dlcBTC", + "offset": 0, + "slot": "257", + "type": "t_contract(DLCBTC)7584", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:57" + }, + { + "label": "btcFeeRecipient", + "offset": 0, + "slot": "258", + "type": "t_string_storage", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:58" + }, + { + "label": "minimumDeposit", + "offset": 0, + "slot": "259", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:59" + }, + { + "label": "maximumDeposit", + "offset": 0, + "slot": "260", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:60" + }, + { + "label": "btcMintFeeRate", + "offset": 0, + "slot": "261", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:61" + }, + { + "label": "btcRedeemFeeRate", + "offset": 0, + "slot": "262", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:62" + }, + { + "label": "whitelistingEnabled", + "offset": 0, + "slot": "263", + "type": "t_bool", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:63" + }, + { + "label": "userVaults", + "offset": 0, + "slot": "264", + "type": "t_mapping(t_address,t_array(t_bytes32)dyn_storage)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:65" + }, + { + "label": "_whitelistedAddresses", + "offset": 0, + "slot": "265", + "type": "t_mapping(t_address,t_bool)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:66" + }, + { + "label": "__gap", + "offset": 0, + "slot": "266", + "type": "t_array(t_uint256)41_storage", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:67" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_bytes32)dyn_storage": { + "label": "bytes32[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)41_storage": { + "label": "uint256[41]", + "numberOfBytes": "1312" + }, + "t_array(t_uint256)48_storage": { + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(DLCBTC)7584": { + "label": "contract DLCBTC", + "numberOfBytes": "20" + }, + "t_enum(DLCStatus)7596": { + "label": "enum DLCLink.DLCStatus", + "members": [ + "READY", + "FUNDED", + "CLOSING", + "CLOSED", + "AUX_STATE_1", + "AUX_STATE_2", + "AUX_STATE_3", + "AUX_STATE_4", + "AUX_STATE_5" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_bytes32)dyn_storage)": { + "label": "mapping(address => bytes32[])", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_struct(RoleData)747_storage)": { + "label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_uint256)": { + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_struct(DLC)7626_storage)": { + "label": "mapping(uint256 => struct DLCLink.DLC)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(DLC)7626_storage": { + "label": "struct DLCLink.DLC", + "members": [ + { + "label": "uuid", + "type": "t_bytes32", + "offset": 0, + "slot": "0" + }, + { + "label": "protocolContract", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "timestamp", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "valueLocked", + "type": "t_uint256", + "offset": 0, + "slot": "3" + }, + { + "label": "creator", + "type": "t_address", + "offset": 0, + "slot": "4" + }, + { + "label": "status", + "type": "t_enum(DLCStatus)7596", + "offset": 20, + "slot": "4" + }, + { + "label": "fundingTxId", + "type": "t_string_storage", + "offset": 0, + "slot": "5" + }, + { + "label": "closingTxId", + "type": "t_string_storage", + "offset": 0, + "slot": "6" + }, + { + "label": "btcFeeRecipient", + "type": "t_string_storage", + "offset": 0, + "slot": "7" + }, + { + "label": "btcMintFeeBasisPoints", + "type": "t_uint256", + "offset": 0, + "slot": "8" + }, + { + "label": "btcRedeemFeeBasisPoints", + "type": "t_uint256", + "offset": 0, + "slot": "9" + }, + { + "label": "taprootPubKey", + "type": "t_string_storage", + "offset": 0, + "slot": "10" + }, + { + "label": "valueMinted", + "type": "t_uint256", + "offset": 0, + "slot": "11" + }, + { + "label": "wdTxId", + "type": "t_string_storage", + "offset": 0, + "slot": "12" + } + ], + "numberOfBytes": "416" + }, + "t_struct(RoleData)747_storage": { + "label": "struct AccessControlUpgradeable.RoleData", + "members": [ + { + "label": "members", + "type": "t_mapping(t_address,t_bool)", + "offset": 0, + "slot": "0" + }, + { + "label": "adminRole", + "type": "t_bytes32", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint48": { + "label": "uint48", + "numberOfBytes": "6" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } + }, + "1a0839198b1f2d291714ac6e8a944dd82a44f70771a22ac79fd79c396ea8492d": { + "address": "0xc05656f69B43Ed4C0d7cCd9b986313E64E8DC96a", + "txHash": "0xad57bbd2039a060e856997b031a1ecc5fcd74899f5f542c089d4e3e8149b9f71", + "layout": { + "solcVersion": "0.8.18", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "__gap", + "offset": 0, + "slot": "51", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC165Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:41" + }, + { + "label": "_roles", + "offset": 0, + "slot": "101", + "type": "t_mapping(t_bytes32,t_struct(RoleData)747_storage)", + "contract": "AccessControlUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:62" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "AccessControlUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:260" + }, + { + "label": "_pendingDefaultAdmin", + "offset": 0, + "slot": "151", + "type": "t_address", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:43" + }, + { + "label": "_pendingDefaultAdminSchedule", + "offset": 20, + "slot": "151", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:44" + }, + { + "label": "_currentDelay", + "offset": 26, + "slot": "151", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:46" + }, + { + "label": "_currentDefaultAdmin", + "offset": 0, + "slot": "152", + "type": "t_address", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:47" + }, + { + "label": "_pendingDelay", + "offset": 20, + "slot": "152", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:50" + }, + { + "label": "_pendingDelaySchedule", + "offset": 26, + "slot": "152", + "type": "t_uint48", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:51" + }, + { + "label": "__gap", + "offset": 0, + "slot": "153", + "type": "t_array(t_uint256)48_storage", + "contract": "AccessControlDefaultAdminRulesUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/AccessControlDefaultAdminRulesUpgradeable.sol:394" + }, + { + "label": "_paused", + "offset": 0, + "slot": "201", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "202", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:116" + }, + { + "label": "_index", + "offset": 0, + "slot": "251", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:47" + }, + { + "label": "dlcs", + "offset": 0, + "slot": "252", + "type": "t_mapping(t_uint256,t_struct(DLC)7626_storage)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:48" + }, + { + "label": "dlcIDsByUUID", + "offset": 0, + "slot": "253", + "type": "t_mapping(t_bytes32,t_uint256)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:49" + }, + { + "label": "_minimumThreshold", + "offset": 0, + "slot": "254", + "type": "t_uint16", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:51" + }, + { + "label": "_threshold", + "offset": 2, + "slot": "254", + "type": "t_uint16", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:52" + }, + { + "label": "_signerCount", + "offset": 4, + "slot": "254", + "type": "t_uint16", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:53" + }, + { + "label": "tssCommitment", + "offset": 0, + "slot": "255", + "type": "t_bytes32", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:54" + }, + { + "label": "attestorGroupPubKey", + "offset": 0, + "slot": "256", + "type": "t_string_storage", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:55" + }, + { + "label": "dlcBTC", + "offset": 0, + "slot": "257", + "type": "t_contract(DLCBTC)7584", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:57" + }, + { + "label": "btcFeeRecipient", + "offset": 0, + "slot": "258", + "type": "t_string_storage", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:58" + }, + { + "label": "minimumDeposit", + "offset": 0, + "slot": "259", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:59" + }, + { + "label": "maximumDeposit", + "offset": 0, + "slot": "260", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:60" + }, + { + "label": "btcMintFeeRate", + "offset": 0, + "slot": "261", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:61" + }, + { + "label": "btcRedeemFeeRate", + "offset": 0, + "slot": "262", + "type": "t_uint256", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:62" + }, + { + "label": "whitelistingEnabled", + "offset": 0, + "slot": "263", + "type": "t_bool", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:63" + }, + { + "label": "userVaults", + "offset": 0, + "slot": "264", + "type": "t_mapping(t_address,t_array(t_bytes32)dyn_storage)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:65" + }, + { + "label": "_whitelistedAddresses", + "offset": 0, + "slot": "265", + "type": "t_mapping(t_address,t_bool)", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:66" + }, + { + "label": "__gap", + "offset": 0, + "slot": "266", + "type": "t_array(t_uint256)41_storage", + "contract": "DLCManager", + "src": "contracts/DLCManager.sol:67" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_bytes32)dyn_storage": { + "label": "bytes32[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)41_storage": { + "label": "uint256[41]", + "numberOfBytes": "1312" + }, + "t_array(t_uint256)48_storage": { + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(DLCBTC)7584": { + "label": "contract DLCBTC", + "numberOfBytes": "20" + }, + "t_enum(DLCStatus)7596": { + "label": "enum DLCLink.DLCStatus", + "members": [ + "READY", + "FUNDED", + "CLOSING", + "CLOSED", + "AUX_STATE_1", + "AUX_STATE_2", + "AUX_STATE_3", + "AUX_STATE_4", + "AUX_STATE_5" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_bytes32)dyn_storage)": { + "label": "mapping(address => bytes32[])", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_struct(RoleData)747_storage)": { + "label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_uint256)": { + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_struct(DLC)7626_storage)": { + "label": "mapping(uint256 => struct DLCLink.DLC)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(DLC)7626_storage": { + "label": "struct DLCLink.DLC", + "members": [ + { + "label": "uuid", + "type": "t_bytes32", + "offset": 0, + "slot": "0" + }, + { + "label": "protocolContract", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "timestamp", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "valueLocked", + "type": "t_uint256", + "offset": 0, + "slot": "3" + }, + { + "label": "creator", + "type": "t_address", + "offset": 0, + "slot": "4" + }, + { + "label": "status", + "type": "t_enum(DLCStatus)7596", + "offset": 20, + "slot": "4" + }, + { + "label": "fundingTxId", + "type": "t_string_storage", + "offset": 0, + "slot": "5" + }, + { + "label": "closingTxId", + "type": "t_string_storage", + "offset": 0, + "slot": "6" + }, + { + "label": "btcFeeRecipient", + "type": "t_string_storage", + "offset": 0, + "slot": "7" + }, + { + "label": "btcMintFeeBasisPoints", + "type": "t_uint256", + "offset": 0, + "slot": "8" + }, + { + "label": "btcRedeemFeeBasisPoints", + "type": "t_uint256", + "offset": 0, + "slot": "9" + }, + { + "label": "taprootPubKey", + "type": "t_string_storage", + "offset": 0, + "slot": "10" + }, + { + "label": "valueMinted", + "type": "t_uint256", + "offset": 0, + "slot": "11" + }, + { + "label": "wdTxId", + "type": "t_string_storage", + "offset": 0, + "slot": "12" + } + ], + "numberOfBytes": "416" + }, + "t_struct(RoleData)747_storage": { + "label": "struct AccessControlUpgradeable.RoleData", + "members": [ + { + "label": "members", + "type": "t_mapping(t_address,t_bool)", + "offset": 0, + "slot": "0" + }, + { + "label": "adminRole", + "type": "t_bytes32", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint48": { + "label": "uint48", + "numberOfBytes": "6" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } } } } diff --git a/contracts/DLCManager.sol b/contracts/DLCManager.sol index fed9619..5411679 100644 --- a/contracts/DLCManager.sol +++ b/contracts/DLCManager.sol @@ -75,7 +75,8 @@ contract DLCManager is error ContractNotWhitelisted(); error NotCreatorContract(); error DLCNotFound(); - error DLCNotReadyOrPending(); + error DLCNotPending(); + error DLCNotReadyOrFunded(); error DLCNotFunded(); error ThresholdMinimumReached(uint16 _minimumThreshold); @@ -333,24 +334,25 @@ contract DLCManager is DLCLink.DLC storage dlc = dlcs[dlcIDsByUUID[uuid]]; if (dlc.uuid == bytes32(0)) revert DLCNotFound(); - if ( - dlc.status != DLCLink.DLCStatus.READY && - dlc.status != DLCLink.DLCStatus.AUX_STATE_1 - ) revert DLCNotReadyOrPending(); + if (dlc.status != DLCLink.DLCStatus.AUX_STATE_1) revert DLCNotPending(); if (newValueLocked < dlc.valueMinted) { // During a withdrawal, a burn should have already happened revert UnderCollateralized(newValueLocked, dlc.valueMinted); } - uint256 amountToMint = newValueLocked - dlc.valueMinted; - if (amountToMint > maximumDeposit) { - revert DepositTooLarge(amountToMint, maximumDeposit); + uint256 amountToLockDiff; + if (newValueLocked > dlc.valueLocked) { + amountToLockDiff = newValueLocked - dlc.valueLocked; + } else { + amountToLockDiff = dlc.valueLocked - newValueLocked; } - - if (amountToMint > 0 && amountToMint < minimumDeposit) { - revert DepositTooSmall(amountToMint, minimumDeposit); + if (amountToLockDiff > maximumDeposit) { + revert DepositTooLarge(amountToLockDiff, maximumDeposit); + } + if (amountToLockDiff < minimumDeposit) { + revert DepositTooSmall(amountToLockDiff, minimumDeposit); } dlc.fundingTxId = btcTxId; @@ -388,18 +390,16 @@ contract DLCManager is uint256 newValueLocked ) external whenNotPaused onlyApprovedSigners { _attestorMultisigIsValid( - abi.encode( - uuid, - wdTxId, - "set-status-redeem-pending", - newValueLocked - ), + abi.encode(uuid, wdTxId, "set-status-pending", newValueLocked), signatures ); DLCLink.DLC storage dlc = dlcs[dlcIDsByUUID[uuid]]; if (dlc.uuid == bytes32(0)) revert DLCNotFound(); - if (dlc.status != DLCLink.DLCStatus.FUNDED) revert DLCNotFunded(); + if ( + dlc.status != DLCLink.DLCStatus.READY && + dlc.status != DLCLink.DLCStatus.FUNDED + ) revert DLCNotReadyOrFunded(); dlc.status = DLCLink.DLCStatus.AUX_STATE_1; dlc.wdTxId = wdTxId; diff --git a/deploymentFiles/arbsepolia/DLCManager.json b/deploymentFiles/arbsepolia/DLCManager.json index 72da15f..2d2a25a 100644 --- a/deploymentFiles/arbsepolia/DLCManager.json +++ b/deploymentFiles/arbsepolia/DLCManager.json @@ -1,7 +1,7 @@ { "network": "arbsepolia", - "updatedAt": "2024-07-11T11:44:29.251Z", - "gitSHA": "ab30e2b", + "updatedAt": "2024-07-15T15:09:23.623Z", + "gitSHA": "13f76b6", "contract": { "name": "DLCManager", "address": "0xE8FA6399d1b60968f04888F23Ed13Ed499C1Fd51", @@ -12,7 +12,8 @@ "error ContractNotWhitelisted()", "error DLCNotFound()", "error DLCNotFunded()", - "error DLCNotReadyOrPending()", + "error DLCNotPending()", + "error DLCNotReadyOrFunded()", "error DepositTooLarge(uint256 deposit, uint256 maximumDeposit)", "error DepositTooSmall(uint256 deposit, uint256 minimumDeposit)", "error DuplicateSignature()", diff --git a/test/DLCBTC.test.js b/test/DLCBTC.test.js index 5cc6dbc..a2c7107 100644 --- a/test/DLCBTC.test.js +++ b/test/DLCBTC.test.js @@ -119,7 +119,17 @@ describe('DLCBTC', function () { const _uuid = await receipt.events[0].args.uuid; await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytesForPending = await getSignatures( + { + uuid: _uuid, + btcTxId: mockBTCTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const signatureBytesForFunding = await getSignatures( { uuid: _uuid, btcTxId: mockBTCTxId, @@ -130,15 +140,24 @@ describe('DLCBTC', function () { 3 ); const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending( + _uuid, + mockBTCTxId, + signatureBytesForPending, + 0 + ); + await tx2.wait(); + const tx3 = await dlcManager .connect(attestor1) .setStatusFunded( _uuid, mockBTCTxId, - signatureBytes, + signatureBytesForFunding, mockTaprootPubkey, deposit ); - await tx2.wait(); + await tx3.wait(); const expectedBalance = ethers.BigNumber.from(existingBalance).add( ethers.BigNumber.from(deposit) ); @@ -170,7 +189,17 @@ describe('DLCBTC', function () { const _uuid = await receipt.events[0].args.uuid; await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytesForPending = await getSignatures( + { + uuid: _uuid, + btcTxId: mockBTCTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const signatureBytesForFunding = await getSignatures( { uuid: _uuid, btcTxId: mockBTCTxId, @@ -181,25 +210,33 @@ describe('DLCBTC', function () { 3 ); const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending( + _uuid, + mockBTCTxId, + signatureBytesForPending, + 0 + ); + await tx2.wait(); + const tx3 = await dlcManager .connect(attestor1) .setStatusFunded( _uuid, mockBTCTxId, - signatureBytes, + signatureBytesForFunding, mockTaprootPubkey, deposit ); - await tx2.wait(); - + await tx3.wait(); expect(await dlcBtc.balanceOf(user.address)).to.equal( ethers.BigNumber.from(existingBalance).add( ethers.BigNumber.from(deposit) ) ); - const tx3 = await dlcManager + const tx4 = await dlcManager .connect(user) .withdraw(mockUUID, deposit); - await tx3.wait(); + await tx4.wait(); expect(await dlcBtc.balanceOf(user.address)).to.equal( existingBalance diff --git a/test/DLCManager.test.js b/test/DLCManager.test.js index f30b752..4e15cff 100644 --- a/test/DLCManager.test.js +++ b/test/DLCManager.test.js @@ -254,7 +254,17 @@ describe('DLCManager', () => { it('returns the correct data', async () => { await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const signatureBytesForFunding = await getSignatures( { uuid, btcTxId, @@ -265,15 +275,19 @@ describe('DLCManager', () => { 3 ); const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); + const tx3 = await dlcManager .connect(attestor1) .setStatusFunded( uuid, btcTxId, - signatureBytes, + signatureBytesForFunding, mockTaprootPubkey, valueLocked ); - await tx2.wait(); + await tx3.wait(); const data = await dlcManager.getDLC(uuid); expect(data.creator).to.equal(user.address); @@ -293,7 +307,17 @@ describe('DLCManager', () => { uuid = decodedEvent.args.uuid; await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const signatureBytesForFunding = await getSignatures( { uuid, btcTxId, @@ -304,15 +328,19 @@ describe('DLCManager', () => { 3 ); const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); + const tx3 = await dlcManager .connect(attestor1) .setStatusFunded( uuid, btcTxId, - signatureBytes, + signatureBytesForFunding, mockTaprootPubkey, valueLocked ); - await tx2.wait(); + await tx3.wait(); }); it('returns 0s if called with a non-existing index', async () => { @@ -339,11 +367,26 @@ describe('DLCManager', () => { const event = receipt.events[0]; const decodedEvent = dlcManager.interface.parseLog(event); uuid = decodedEvent.args.uuid; + + await setSigners(dlcManager, attestors); + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); }); it('reverts if called without enough signatures', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -367,8 +410,7 @@ describe('DLCManager', () => { }); it('reverts if contains non-approved signer', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -393,8 +435,7 @@ describe('DLCManager', () => { }); it('reverts if signature is for other function', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -418,9 +459,8 @@ describe('DLCManager', () => { ).to.be.revertedWithCustomError(dlcManager, 'InvalidSigner'); }); - xit('reverts if DLC is not in the right state', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + it('reverts if DLC is not in the right state', async () => { + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -442,8 +482,6 @@ describe('DLCManager', () => { ); await tx2.wait(); - await dlcManager.connect(user).closeVault(uuid); - const sigs = await getSignatures( { uuid, @@ -461,18 +499,17 @@ describe('DLCManager', () => { .setStatusFunded( uuid, btcTxId2, - sigs.signatureBytes, + sigs, mockTaprootPubkey, valueLocked ) - ).to.be.revertedWithCustomError(dlcManager, 'DLCNotReady'); + ).to.be.revertedWithCustomError(dlcManager, 'DLCNotPending'); }); it('reverts if attestors sign a different UUID', async () => { - await setSigners(dlcManager, attestors); const wrongUUID = '0x96eecb386fb10e82f510aaf3e2b99f52f8dcba03f9e0521f7551b367d8ad4968'; - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid: wrongUUID, btcTxId, @@ -496,10 +533,9 @@ describe('DLCManager', () => { }); it('reverts if attestors sign a different btcTxId', async () => { - await setSigners(dlcManager, attestors); const wrongBtcTxId = '0x96eecb386fb10e82f510aaf3e2b99f52f8dcba03f9e0521f7551b367d8ad4968'; - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId: wrongBtcTxId, @@ -523,8 +559,7 @@ describe('DLCManager', () => { }); it('reverts if signatures are not unique', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -548,8 +583,7 @@ describe('DLCManager', () => { }); it('reverts if deposit is too large', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -573,8 +607,7 @@ describe('DLCManager', () => { }); it('reverts if deposit is too small', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -602,8 +635,7 @@ describe('DLCManager', () => { const tx = await dlcManager.connect(user).setupVault(); await tx.wait(); - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -627,8 +659,7 @@ describe('DLCManager', () => { }); it('emits a StatusFunded event with the correct data', async () => { - await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( + const signatureBytes = await getSignatures( { uuid, btcTxId, @@ -658,84 +689,209 @@ describe('DLCManager', () => { }); }); - xdescribe('closeVault', async () => { + describe('Withdraw', async () => { let uuid; - let outcome = 10000; - beforeEach(async () => { await whitelistAddress(dlcManager, user); - const tx = await dlcManager.connect(user).setupVault(valueLocked); + const tx = await dlcManager.connect(user).setupVault(); const receipt = await tx.wait(); const event = receipt.events[0]; const decodedEvent = dlcManager.interface.parseLog(event); uuid = decodedEvent.args.uuid; await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( - { uuid, btcTxId, functionString: 'set-status-funded' }, + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, attestors, 3 ); - await dlcManager + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); + + const signatureBytesForFunding = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: valueLocked, + }, + attestors, + 3 + ); + const tx3 = await dlcManager .connect(attestor1) .setStatusFunded( uuid, btcTxId, - signatureBytes, - mockTaprootPubkey + signatureBytesForFunding, + mockTaprootPubkey, + valueLocked ); + await tx3.wait(); }); - xit('reverts if not called by the creator contract', async () => { - await expect( - dlcManager.connect(randomAccount).closeVault(uuid) - ).to.be.revertedWithCustomError(dlcManager, 'NotOwner'); - }); + it('should be able to withdraw (burn) half the locked tokens', async () => { + const tx = await dlcManager + .connect(user) + .withdraw(uuid, valueLocked / 2); + const getDlcTx = await dlcManager.getDLC(uuid); - it('reverts if DLC is not in the right state', async () => { - const tx = await dlcManager.connect(user).setupVault(valueLocked); - const receipt = await tx.wait(); - const event = receipt.events[0]; - const decodedEvent = dlcManager.interface.parseLog(event); - const newUuid = decodedEvent.args.uuid; + expect(await dlcBtc.balanceOf(user.address)).to.equal( + valueLocked / 2 + ); + expect(getDlcTx.valueMinted).to.equal(valueLocked / 2); - await expect( - dlcManager.connect(user).closeVault(newUuid) - ).to.be.revertedWithCustomError(dlcManager, 'DLCNotFunded'); + // but we haven't redeemed the btc yet + expect(getDlcTx.valueLocked).to.equal(valueLocked); }); - it('reverts if user does not have enough dlcBTC tokens', async () => { - await dlcBtc.connect(user).transfer(randomAccount.address, 5000); - await expect( - dlcManager.connect(user).closeVault(uuid) - ).to.be.revertedWithCustomError( - dlcManager, - 'InsufficientTokenBalance' + it('should be able to redeem bitcoin in the amount you did the withdraw', async () => { + const tx = await dlcManager + .connect(user) + .withdraw(uuid, valueLocked / 2); + + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 ); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); + + const signatureBytesForFunding = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: valueLocked / 2, + }, + attestors, + 3 + ); + const tx3 = await dlcManager + .connect(attestor1) + .setStatusFunded( + uuid, + btcTxId, + signatureBytesForFunding, + mockTaprootPubkey, + valueLocked / 2 + ); + await tx3.wait(); + + expect(await dlcBtc.balanceOf(user.address)).to.equal( + valueLocked / 2 + ); + + const getDlcTx = await dlcManager.getDLC(uuid); + expect(getDlcTx.valueLocked).to.equal(valueLocked / 2); + expect(getDlcTx.valueMinted).to.equal(valueLocked / 2); }); - it('burns the users dlcBTC tokens', async () => { - await dlcManager.connect(user).closeVault(uuid); - expect(await dlcBtc.balanceOf(user.address)).to.equal(0); + + it('should throw an error if you try to redeem more bitcoin than you burned', async () => { + const tx = await dlcManager + .connect(user) + .withdraw(uuid, valueLocked / 2); + + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); + + const signatureBytesForFunding = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: valueLocked / 2 - 1, + }, + attestors, + 3 + ); + await expect( + dlcManager + .connect(attestor1) + .setStatusFunded( + uuid, + btcTxId, + signatureBytesForFunding, + mockTaprootPubkey, + valueLocked / 2 - 1 + ) + ).to.be.revertedWithCustomError(dlcManager, 'UnderCollateralized'); }); - it('emits a CloseDLC event with the correct data', async () => { - const tx = await dlcManager.connect(user).closeVault(uuid); - const receipt = await tx.wait(); - const event = receipt.events.find((e) => e.event === 'CloseDLC'); + it('should throw an error if you try to call setStatusFunded with too low a number', async () => { + const tx = await dlcManager + .connect(user) + .withdraw(uuid, valueLocked - 1); - const decodedEvent = dlcManager.interface.parseLog(event); + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); - expect(decodedEvent.name).to.equal('CloseDLC'); - expect(decodedEvent.args.uuid).to.equal(uuid); - expect(decodedEvent.args.sender).to.equal(user.address); + const signatureBytesForFunding = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: valueLocked - 1, + }, + attestors, + 3 + ); + await expect( + dlcManager + .connect(attestor1) + .setStatusFunded( + uuid, + btcTxId, + signatureBytesForFunding, + mockTaprootPubkey, + valueLocked - 1 + ) + ).to.be.revertedWithCustomError(dlcManager, 'DepositTooSmall'); }); }); - xdescribe('postCloseDLC', async () => { + describe('Deposit', async () => { let uuid; - const closingBtcTxId = '0x1234567890123'; - beforeEach(async () => { await whitelistAddress(dlcManager, user); @@ -746,8 +902,28 @@ describe('DLCManager', () => { uuid = decodedEvent.args.uuid; await setSigners(dlcManager, attestors); - const { signatureBytes } = await getSignatures( - { uuid, btcTxId, functionString: 'set-status-funded' }, + const signatureBytesForPending = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, + }, + attestors, + 3 + ); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); + + const signatureBytesForFunding = await getSignatures( + { + uuid, + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: valueLocked, + }, attestors, 3 ); @@ -756,112 +932,98 @@ describe('DLCManager', () => { .setStatusFunded( uuid, btcTxId, - signatureBytes, - mockTaprootPubkey + signatureBytesForFunding, + mockTaprootPubkey, + valueLocked ); await tx3.wait(); - const tx4 = await dlcManager.connect(user).closeVault(uuid); - await tx4.wait(); }); - it('reverts if DLC is not in the right state', async () => { - const tx = await dlcManager.connect(user).setupVault(valueLocked); - const receipt = await tx.wait(); - const event = receipt.events[0]; - const decodedEvent = dlcManager.interface.parseLog(event); - const newUuid = decodedEvent.args.uuid; - - const { signatureBytes } = await getSignatures( + it('should be able to deposit more bitcoin', async () => { + const lockedAmountAfterDeposit = valueLocked + valueLocked / 2; + const signatureBytesForPending = await getSignatures( { - uuid: newUuid, - btcTxId: closingBtcTxId, - functionString: 'post-close-dlc', + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, }, attestors, 3 ); - await expect( - dlcManager - .connect(attestor1) - .postCloseDLC(newUuid, closingBtcTxId, signatureBytes) - ).to.be.revertedWithCustomError(dlcManager, 'DLCNotClosing'); - }); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); - it('reverts if called without enough signatures', async () => { - const { signatureBytes } = await getSignatures( + const signatureBytesForFunding = await getSignatures( { uuid, - btcTxId: closingBtcTxId, - functionString: 'post-close-dlc', + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: lockedAmountAfterDeposit, }, attestors, - 1 + 3 ); - await expect( - dlcManager - .connect(attestor1) - .postCloseDLC(uuid, closingBtcTxId, signatureBytes) - ).to.be.revertedWithCustomError(dlcManager, 'NotEnoughSignatures'); - }); - - xit('reverts if contains non-approved signer', async () => { - const { signatureBytes } = await getSignatures( - { + const tx3 = await dlcManager + .connect(attestor1) + .setStatusFunded( uuid, - btcTxId: closingBtcTxId, - functionString: 'post-close-dlc', - }, - [...attestors, randomAccount], - 4 + btcTxId, + signatureBytesForFunding, + mockTaprootPubkey, + lockedAmountAfterDeposit + ); + await tx3.wait(); + + expect(await dlcBtc.balanceOf(user.address)).to.equal( + lockedAmountAfterDeposit ); - await expect( - dlcManager - .connect(attestor1) - .postCloseDLC(uuid, closingBtcTxId, signatureBytes) - ).to.be.revertedWithCustomError(dlcManager, 'InvalidSigner'); + const getDlcTx = await dlcManager.getDLC(uuid); + expect(getDlcTx.valueLocked).to.equal(lockedAmountAfterDeposit); + expect(getDlcTx.valueMinted).to.equal(lockedAmountAfterDeposit); }); - it('reverts if attestors sign a different UUID', async () => { - const wrongUUID = - '0x96eecb386fb10e82f510aaf3e2b99f52f8dcba03f9e0521f7551b367d8ad4968'; - const { signatureBytes } = await getSignatures( + it('should throw an error if you try to despoit more bitcoin than allowed', async () => { + const lockedAmountAfterDeposit = valueLocked * 100; + const signatureBytesForPending = await getSignatures( { - uuid: wrongUUID, - btcTxId: closingBtcTxId, - functionString: 'post-close-dlc', + uuid, + btcTxId, + functionString: 'set-status-pending', + newLockedAmount: 0, }, attestors, 3 ); - await expect( - dlcManager - .connect(attestor1) - .postCloseDLC(uuid, closingBtcTxId, signatureBytes) - ).to.be.revertedWithCustomError(dlcManager, 'InvalidSigner'); - }); + const tx2 = await dlcManager + .connect(attestor1) + .setStatusPending(uuid, btcTxId, signatureBytesForPending, 0); + await tx2.wait(); - it('emits a PostCloseDLC event with the correct data', async () => { - const { signatureBytes } = await getSignatures( + const signatureBytesForFunding = await getSignatures( { uuid, - btcTxId: closingBtcTxId, - functionString: 'post-close-dlc', + btcTxId, + functionString: 'set-status-funded', + newLockedAmount: lockedAmountAfterDeposit, }, attestors, 3 ); - const tx = await dlcManager - .connect(attestor1) - .postCloseDLC(uuid, closingBtcTxId, signatureBytes); - const receipt = await tx.wait(); - const event = receipt.events.find( - (e) => e.event === 'PostCloseDLC' - ); - - expect(event.event).to.equal('PostCloseDLC'); - expect(event.args.uuid).to.equal(uuid); - expect(event.args.btcTxId).to.equal(closingBtcTxId); + await expect( + dlcManager + .connect(attestor1) + .setStatusFunded( + uuid, + btcTxId, + signatureBytesForFunding, + mockTaprootPubkey, + lockedAmountAfterDeposit + ) + ).to.be.revertedWithCustomError(dlcManager, 'DepositTooLarge'); }); }); }); diff --git a/test/utils.js b/test/utils.js index 7365ce0..04070a5 100644 --- a/test/utils.js +++ b/test/utils.js @@ -21,7 +21,7 @@ async function getSignatures(message, attestors, numberOfSignatures) { signatureBytes.push(ethers.utils.arrayify(sig)); } // Convert signatures from strings to bytes - return { signatureBytes }; + return signatureBytes; } async function setSigners(dlcManager, attestors) {