Verified contractPartial
DealManager
Address0xc77aba9512821a839bdb74d7b43cf8dffd70eca6
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 15 runs
- EVM version
- prague
- Via IR
- yes
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,300,441
- Creation transaction
- 0x784d2150fd…c5d2cffa99
- Libraries
- src/CyberAgreementRegistry.sol:CyberAgreementJson0x7ccd…ec9e8esrc/CyberAgreementRegistry.sol:CyberAgreementBound0xe878…e93415src/storage/LexScrowStorage.sol:LexScrowStorage0xe060…24d49dsrc/creds/LeXcheXBadgeRender.sol:LeXcheXBadgeRender0xb62c…5c99a2src/storage/DealManagerStorage.sol:DealManagerStorage0x1745…aee644src/storage/RoundManagerStorage.sol:RoundManagerStorage0xfdb8…aa3813src/storage/SecondaryTradeStorage.sol:SecondaryTradeStorage0xe658…520e86src/CertificateImageContentBuilder.sol:CertificateImageContentBuilder0xf73c…eb4c1dsrc/storage/IssuanceManagerStorage.sol:IssuanceManagerStorage0xbc28…e1220csrc/storage/LedgerEntryTokenStorage.sol:LedgerEntryTokenStorage0xe720…5c4a05src/storage/extensions/ShareCertDataLayerLib.sol:ShareCertDataLayerLib0x7802…70468c
65 files
The source code is large: one file is shown at a time. Choose a file in the list.
- src/DealManager.solmain38.06 KB
- dependencies/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol9.28 KB
- dependencies/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol6.57 KB
- dependencies/openzeppelin-contracts/contracts/access/Ownable.sol3.1 KB
- dependencies/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4.45 KB
- dependencies/openzeppelin-contracts/contracts/interfaces/IERC165.sol192 B
- dependencies/openzeppelin-contracts/contracts/interfaces/IERC1967.sol636 B
- dependencies/openzeppelin-contracts/contracts/interfaces/IERC20.sol181 B
- dependencies/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol881 B
- dependencies/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol6.24 KB
- dependencies/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol472 B
- dependencies/openzeppelin-contracts/contracts/proxy/beacon/UpgradeableBeacon.sol2.22 KB
- dependencies/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol4.75 KB
- dependencies/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- dependencies/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol10.08 KB
- dependencies/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol4.93 KB
- dependencies/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Enumerable.sol1.04 KB
- dependencies/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol792 B
- dependencies/openzeppelin-contracts/contracts/utils/Address.sol6.05 KB
- dependencies/openzeppelin-contracts/contracts/utils/Context.sol963 B
- dependencies/openzeppelin-contracts/contracts/utils/Errors.sol896 B
- dependencies/openzeppelin-contracts/contracts/utils/Panic.sol1.97 KB
- dependencies/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol3.38 KB
- dependencies/openzeppelin-contracts/contracts/utils/StorageSlot.sol4.18 KB
- dependencies/openzeppelin-contracts/contracts/utils/Strings.sol18.95 KB
- dependencies/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol7.82 KB
- dependencies/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol4.25 KB
- dependencies/openzeppelin-contracts/contracts/utils/introspection/ERC165Checker.sol5.05 KB
- dependencies/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol870 B
- dependencies/openzeppelin-contracts/contracts/utils/math/Math.sol32.15 KB
- dependencies/openzeppelin-contracts/contracts/utils/math/SafeCast.sol34.94 KB
- dependencies/openzeppelin-contracts/contracts/utils/math/SignedMath.sol2.61 KB
- src/CyberCorpConstants.sol6.63 KB
- src/creds/storage/lexchexBadgeStorage.sol8.27 KB
- src/interfaces/FeeTypes.sol4.06 KB
- src/interfaces/IAuthAdapter.sol3.91 KB
- src/interfaces/ICondition.sol3.85 KB
- src/interfaces/ICyberAgreementRegistry.sol7.81 KB
- src/interfaces/ICyberCorp.sol5.86 KB
- src/interfaces/IDealManager.sol6.82 KB
- src/interfaces/IDealManagerFactory.sol5.61 KB
- src/interfaces/IDealManagerStorage.sol3.34 KB
- src/interfaces/IERC5484.sol670 B
- src/interfaces/IIssuanceManager.sol14.27 KB
- src/interfaces/ILedgerEntryToken.sol15.73 KB
- src/interfaces/ILexChexBadge.sol14.47 KB
- src/interfaces/ILexScrowStorage.sol3.4 KB
- src/interfaces/ISecondaryTradeStorage.sol17.6 KB
- src/interfaces/ITransferRestrictionHook.sol5.25 KB
- src/interfaces/IUriBuilder.sol6.55 KB
- src/libs/EIP712Lib.sol4.49 KB
- src/libs/JsonLib.sol7.29 KB
- src/libs/auth.sol9.6 KB
- src/libs/conditions/BaseSecondaryTradingCondition.sol2.61 KB
- src/libs/policies/LookThroughPolicy.sol3.31 KB
- src/libs/policies/USJurisdictionPolicy.sol873 B
- src/storage/BorgAuthStorage.sol4.39 KB
- src/storage/DealManagerFactoryStorage.sol6.23 KB
- src/storage/DealManagerStorage.sol21.89 KB
- src/storage/LedgerEntryTokenStorage.sol59.07 KB
- src/storage/LexScrowStorage.sol20.3 KB
- src/storage/SecondaryTradeStorage.sol58.43 KB
- src/storage/extensions/FundInterestExtensionV3.sol19.79 KB
- src/storage/extensions/ICertificateExtension.sol6.59 KB
- src/storage/extensions/ScopedDataLayerLib.sol2.93 KB
src/DealManager.sol
/* .o.
.888.
.8"888.
.8' `888.
.88ooo8888.
.8' `888.
o88o o8888o
ooo ooooo . ooooo ooooooo ooooo
`88. .888' .o8 `888' `8888 d8'
888b d'888 .ooooo. .o888oo .oooo. 888 .ooooo. Y888..8P
8 Y88. .P 888 d88' `88b 888 `P )88b 888 d88' `88b `8888'
8 `888' 888 888ooo888 888 .oP"888 888 888ooo888 .8PY888.
8 Y 888 888 .o 888 . d8( 888 888 o 888 .o d8' `888b
o8o o888o `Y8bod8P' "888" `Y888""8o o888ooooood8 `Y8bod8P' o888o o88888o
.oooooo. .o8 .oooooo.
d8P' `Y8b "888 d8P' `Y8b
888 oooo ooo 888oooo. .ooooo. oooo d8b 888 .ooooo. oooo d8b oo.ooooo.
888 `88. .8' d88' `88b d88' `88b `888""8P 888 d88' `88b `888""8P 888' `88b
888 `88..8' 888 888 888ooo888 888 888 888 888 888 888 888
`88b ooo `888' 888 888 888 .o 888 `88b ooo 888 888 888 888 888 .o.
`Y8bood8P' .8' `Y8bod8P' `Y8bod8P' d888b `Y8bood8P' `Y8bod8P' d888b 888bod8P' Y8P
.o..P' 888
`Y8P' o888o
_______________________________________________________________________________________________________
All software, documentation and other files and information in this repository (collectively, the "Software")
are copyright MetaLeX Labs, Inc., a Delaware corporation.
All rights reserved.
The Software is proprietary and shall not, in part or in whole, be used, copied, modified, merged, published,
distributed, transmitted, sublicensed, sold, or otherwise used in any form or by any means, electronic or
mechanical, including photocopying, recording, or by any information storage and retrieval system,
except with the express prior written permission of the copyright holder.*/
pragma solidity 0.8.28;
import "openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol";
import "openzeppelin-contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "openzeppelin-contracts/utils/ReentrancyGuard.sol";
import "openzeppelin-contracts/token/ERC20/IERC20.sol";
import "openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IIssuanceManager.sol";
import "./libs/auth.sol";
import "./storage/DealManagerStorage.sol";
import "./storage/DealManagerFactoryStorage.sol";
import "./storage/BorgAuthStorage.sol";
import "./storage/SecondaryTradeStorage.sol";
import "./interfaces/ICyberCorp.sol";
import "./interfaces/IDealManager.sol";
import "./interfaces/IDealManagerStorage.sol";
import "./interfaces/ISecondaryTradeStorage.sol";
import "./interfaces/ILexScrowStorage.sol";
import "./interfaces/IDealManagerFactory.sol";
import "./interfaces/ILedgerEntryToken.sol";
import "./interfaces/ICyberAgreementRegistry.sol";
/// @title DealManager
/// @notice Manages the lifecycle of deals between parties, including creation, signing, payment, and finalization for a CyberCorp
/// @dev Implements UUPS upgradeable pattern and integrates with BorgAuth for access control
contract DealManager is
Initializable,
BorgAuthACL,
UUPSUpgradeable,
ReentrancyGuard,
IDealManager,
IDealManagerStorage,
ISecondaryTradeStorage,
ILexScrowStorage
{
using DealManagerStorage for DealManagerStorage.DealManagerData;
using SafeERC20 for IERC20;
string public constant DEPLOY_VERSION = "5"; // For version-tracking on all deployment and future upgrades
// Library-emitted events/errors are inherited from the per-library interfaces (IDealManagerStorage,
// ISecondaryTradeStorage and ILexScrowStorage) so their selectors/topics appear in DealManager's ABI.
// The errors/event below are owned and used directly by DealManager. (Shared
error ZeroAddress();
error PartyValuesLengthMismatch();
error ConditionAlreadyExists();
error ConditionDoesNotExist();
error NotRefImplementation();
event MinTradeThresholdSet(uint256 minUnits, uint256 minConsideration, address setter);
event SettlementWindowSet(uint256 window, address setter);
event DealRegistrySet(address indexed dealRegistry, address indexed oldDealRegistry, address setter);
event CorpSet(address indexed corp, address indexed oldCorp, address setter);
event IssuanceManagerSet(address indexed issuanceManager, address indexed oldIssuanceManager, address setter);
event DefaultIntegratorSet(address indexed integrator, address indexed oldIntegrator, address setter);
/// @notice Maps agreement IDs to arrays of counter party values for closed deals.
mapping(bytes32 => string[]) public counterPartyValues;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @notice Initializes the DealManager contract
/// @dev Sets up the contract with required addresses and initializes parent contracts
/// @param _auth Address of the BorgAuth contract
/// @param _corp Address of the CyberCorp
/// @param _dealRegistry Address of the CyberAgreementRegistry
/// @param _issuanceManager Address of the CyberCorp's issuance manager
function initialize(address _auth, address _corp, address _dealRegistry, address _issuanceManager, address _upgradeFactory) public initializer {
__BorgAuthACL_init(_auth);
if (_corp == address(0)) revert ZeroAddress();
if (_dealRegistry == address(0)) revert ZeroAddress();
if (_issuanceManager == address(0)) revert ZeroAddress();
// Set storage values
DealManagerStorage.setIssuanceManager(_issuanceManager);
// Initialize LexScrowStorage core addresses (LexScrowStorage is now a library — set storage directly)
LexScrowStorage.setCorp(_corp);
LexScrowStorage.setDealRegistry(_dealRegistry);
DealManagerStorage.setUpgradeFactory(_upgradeFactory);
}
/// @notice Proposes a new deal
/// @dev Creates a new agreement and certificate for the deal
/// @param _certPrinterAddress Array of certificate printer addresses
/// @param _paymentToken Address of the token used for payment
/// @param _paymentAmount Amount to be paid
/// @param _templateId ID of the agreement template to use
/// @param _salt Random value for unique agreement ID generation
/// @param _globalValues Array of global values for the agreement, must match the template
/// @param _parties Array of party addresses
/// @param _certDetails Details of the certificate to be created
/// @param _partyValues Array of party-specific values, must match the template
/// @param conditions Array of condition contract addresses
/// @param secretHash Hash of the secret required for finalization (if any)
/// @param expiry Timestamp when the deal expires
/// @return agreementId Unique identifier for the agreement
/// @return certIds IDs of the created certificate
function proposeDeal(
address[] memory _certPrinterAddress,
address _paymentToken,
uint256 _paymentAmount,
bytes32 _templateId,
uint256 _salt,
string[] memory _globalValues,
address[] memory _parties,
CertificateDetails[] memory _certDetails,
string[][] memory _partyValues,
address[] memory conditions,
bytes32 secretHash,
uint256 expiry
) public onlyOwner returns (bytes32 agreementId, uint256[] memory certIds) {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
return DealManagerStorage.proposeDeal(
_certPrinterAddress, _paymentToken, _paymentAmount, _templateId, _salt,
_globalValues, _parties, _certDetails, _partyValues, conditions, secretHash, expiry
);
}
/// @notice Proposes and signs a deal in one transaction
/// @dev Combines deal proposal and initial signature
/// @param _certPrinterAddress Array of certificate printer addresses
/// @param _paymentToken Address of the token used for payment
/// @param _paymentAmount Amount to be paid
/// @param _templateId ID of the agreement template to use
/// @param _salt Random value for unique agreement ID generation
/// @param _globalValues Array of global values for the agreement, must match the template
/// @param _parties Array of party addresses
/// @param _certDetails Details of the certificate to be created
/// @param proposer Address of the deal proposer
/// @param signature Signature of the proposer
/// @param _partyValues Array of party-specific values, must match the template
/// @param conditions Array of condition contract addresses
/// @param secretHash Hash of the secret required for finalization (if any)
/// @param expiry Timestamp when the deal expires
/// @return agreementId Unique identifier for the agreement
/// @return certIds IDs of the created certificate
function proposeAndSignDeal(
address[] memory _certPrinterAddress,
address _paymentToken,
uint256 _paymentAmount,
bytes32 _templateId,
uint256 _salt,
string[] memory _globalValues,
address[] memory _parties,
CertificateDetails[] memory _certDetails,
address proposer,
bytes memory signature,
string[][] memory _partyValues,
address[] memory conditions,
bytes32 secretHash,
uint256 expiry
) public onlyOwner returns (bytes32 agreementId, uint256[] memory certIds) {
// Implemented here (not in DealManagerStorage) on purpose: keeping proposeAndSignDeal out of that
// library stops the via-ir Yul optimizer from inlining proposeDeal into it (which overflows the
// stack). proposeDeal is reached via a cross-contract delegatecall, so its heavy body stays in the
// linked library and is never inlined here.
if(_partyValues.length > _parties.length) revert PartyValuesLengthMismatch();
(agreementId, certIds) = DealManagerStorage.proposeDeal(
_certPrinterAddress, _paymentToken, _paymentAmount, _templateId, _salt,
_globalValues, _parties, _certDetails, _partyValues, conditions, secretHash, expiry
);
// NOTE: proposer is expected to be listed as a party in the parties array.
// Update the escrow signature
Escrow storage escrow = LexScrowStorage.getEscrow(agreementId);
escrow.signature = signature;
if(_partyValues.length > 1) {
if(_partyValues[1].length != _partyValues[0].length) revert PartyValuesLengthMismatch();
DealManagerStorage.setCounterPartyValues(agreementId, _partyValues[1]);
}
ICyberAgreementRegistry(LexScrowStorage.getDealRegistry()).signContractFor(proposer, agreementId, _partyValues[0], signature, false, "");
}
/// @notice Signs a deal and processes payment
/// @dev Validates signature and processes payment for the deal
/// @param signer Address of the signer
/// @param agreementId Unique identifier for the agreement
/// @param signature Digital Signature hash of the signer
/// @param partyValues Array of party-specific values, must match the template
/// @param _fillUnallocated Whether to fill unallocated slots
/// @param name Name of the signer
/// @param secret Secret required for finalization (if any)
function signDealAndPay(
address signer,
bytes32 agreementId,
bytes memory signature,
string[] memory partyValues,
bool _fillUnallocated,
string memory name,
string memory secret
) public {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
DealManagerStorage.signDealAndPay(signer, agreementId, signature, partyValues, _fillUnallocated, name, secret);
}
/// @notice Signs and finalizes a deal in one transaction
/// @dev Combines signing, payment, and finalization steps
/// @param signer Address of the signer
/// @param agreementId Unique identifier for the agreement
/// @param partyValues Array of party-specific values, must match the template
/// @param signature Digital Signature hash of the signer
/// @param _fillUnallocated Whether to fill unallocated slots
/// @param name Name of the signer
/// @param secret Secret required for finalization (if any)
function signAndFinalizeDeal(
address signer,
bytes32 agreementId,
string[] memory partyValues,
bytes memory signature,
bool _fillUnallocated,
string memory name,
string memory secret
) public nonReentrant {
// Thin wrapper over the linked DealManagerStorage logic. nonReentrant is required here because the
// moved logic invokes finalizeDeal as an internal library call that no longer passes through the
// guarded finalizeDeal wrapper below.
DealManagerStorage.signAndFinalizeDeal(signer, agreementId, partyValues, signature, _fillUnallocated, name, secret);
}
/// @notice Finalizes a deal
/// @dev Checks signatures, conditions and finalizes the agreement
/// @param agreementId Unique identifier for the agreement
function finalizeDeal(bytes32 agreementId) public nonReentrant {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
DealManagerStorage.finalizeDeal(agreementId);
}
/// @notice Voids an expired deal
/// @dev Voids the certificate and agreement for an expired deal
/// @param agreementId Unique identifier for the agreement
/// @param signer Address of the signer
/// @param signature Signature of the signer
function voidExpiredDeal(bytes32 agreementId, address signer, bytes memory signature) public nonReentrant {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
DealManagerStorage.voidExpiredDeal(agreementId, signer, signature);
}
/// @notice Revokes a pending deal
/// @dev Can only be called for deals in pending status
/// @param agreementId Unique identifier for the agreement
/// @param signer Address of the signer
/// @param signature Signature of the signer
function revokeDeal(bytes32 agreementId, address signer, bytes memory signature) public {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
DealManagerStorage.revokeDeal(agreementId, signer, signature);
}
/// @notice Signs to void a deal
/// @dev If the deal is paid, initiates refund process
/// @param agreementId Unique identifier for the agreement
/// @param signer Address of the signer
/// @param signature Signature of the signer
function signToVoid(bytes32 agreementId, address signer, bytes memory signature) public nonReentrant {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
DealManagerStorage.signToVoid(agreementId, signer, signature);
}
/// @notice Refund a voided deal
/// @dev Use this method to initiate refund if the deal agreement has been voided externally
/// (e.g. directly to CyberAgreementRegistry without being processed by Deal Manager)
/// @param agreementId Unique identifier for the agreement
function refundVoidedDeal(bytes32 agreementId) public nonReentrant {
// Thin wrapper over the linked DealManagerStorage logic (delegatecall keeps storage/msg.sender)
DealManagerStorage.refundVoidedDeal(agreementId);
}
/// @notice Adds a condition to a deal
/// @dev Can only be called by owner for pending deals
/// @param agreementId Unique identifier for the agreement
/// @param condition Address of the condition contract to add
function addCondition(bytes32 agreementId, address condition) public onlyOwner {
//make sure the contract is still pending
if(LexScrowStorage.getEscrow(agreementId).status != EscrowStatus.PENDING) revert DealNotPending();
//make sure the condition is not already in the list
ICondition[] storage conditions = LexScrowStorage.getConditionsByEscrow(agreementId);
for(uint256 i = 0; i < conditions.length; i++) {
if(conditions[i] == ICondition(condition)) revert ConditionAlreadyExists();
}
LexScrowStorage.addConditionToEscrow(agreementId, ICondition(condition));
}
/// @notice Removes a condition from a deal
/// @dev Can only be called by owner for pending deals
/// @param agreementId Unique identifier for the agreement
/// @param index Index of the condition to remove
function removeConditionAt(bytes32 agreementId, uint256 index) public onlyOwner {
//make sure the contract is still pending
if(LexScrowStorage.getEscrow(agreementId).status != EscrowStatus.PENDING) revert DealNotPending();
//make sure the condition is in the list
ICondition[] storage conditions = LexScrowStorage.getConditionsByEscrow(agreementId);
if(index >= conditions.length) revert ConditionDoesNotExist();
LexScrowStorage.removeConditionFromEscrow(agreementId, index);
}
/// @notice Sets the deal registry address
/// @dev Can only be called by owner
/// @param _dealRegistry New deal registry address
function setDealRegistry(address _dealRegistry) public onlyOwner {
address oldDealRegistry = LexScrowStorage.getDealRegistry();
LexScrowStorage.setDealRegistry(_dealRegistry);
emit DealRegistrySet(_dealRegistry, oldDealRegistry, msg.sender);
}
/// @notice Sets the corporation address
/// @dev Can only be called by owner
/// @param _corp New corporation address
function setCorp(address _corp) public onlyOwner {
address oldCorp = LexScrowStorage.getCorp();
LexScrowStorage.setCorp(_corp);
emit CorpSet(_corp, oldCorp, msg.sender);
}
/// @notice Sets the issuance manager address
/// @dev Can only be called by owner
/// @param _issuanceManager New issuance manager address
function setIssuanceManager(address _issuanceManager) public onlyOwner {
address oldIssuanceManager = address(DealManagerStorage.getIssuanceManager());
DealManagerStorage.setIssuanceManager(_issuanceManager);
emit IssuanceManagerSet(_issuanceManager, oldIssuanceManager, msg.sender);
}
/// @notice Gets the current issuance manager
/// @return IIssuanceManager The current issuance manager contract
function issuanceManager() public view returns (IIssuanceManager) {
return DealManagerStorage.getIssuanceManager();
}
/// @notice Gets the counter party values for an agreement
/// @param agreementId Unique identifier for the agreement
/// @return string[] Array of counter party values
function getCounterPartyValues(bytes32 agreementId) public view returns (string[] memory) {
return DealManagerStorage.getCounterPartyValues(agreementId);
}
/// @notice Creates an offer for an existing CyberCorp
/// @dev Creates certificate printers and proposes a deal without deploying a new CyberCorp
/// @param _certData Array of certificate data structures
/// @param _templateId ID of the agreement template to use
/// @param _globalValues Array of global values for the agreement
/// @param _parties Array of party addresses
/// @param _paymentAmount Amount to be paid
/// @param _partyValues Array of party-specific values
/// @param signature Digital signature for the deal
/// @param _details Certificate details for each certificate
/// @param conditions Array of condition contract addresses
/// @param secretHash Hash of secret required for finalization
/// @param expiry Deal expiration timestamp
/// @param stableAddress Address of the stable token for payment
/// @param salt Salt value for unique agreement ID generation
/// @return certPrinterAddress Array of deployed certificate printer addresses
/// @return id Unique agreement ID
/// @return certIds Array of certificate IDs created
function proposeAndSignNewCertsDeal(
uint256 salt,
CyberCertData[] memory _certData,
bytes32 _templateId,
string[] memory _globalValues,
address[] memory _parties,
uint256 _paymentAmount,
string[][] memory _partyValues,
bytes memory signature,
CertificateDetails[] memory _details,
address[] memory conditions,
bytes32 secretHash,
uint256 expiry,
address stableAddress
) external onlyOwner returns (
address[] memory certPrinterAddress,
bytes32 id,
uint256[] memory certIds
) {
// Lives here alongside proposeAndSignDeal (its only internal caller) so that function can stay out of
// DealManagerStorage — see the note on proposeAndSignDeal.
certPrinterAddress = new address[](_certData.length);
// Scope companyName + loop temporaries so they (and _certData) are freed before the heavy
// proposeAndSignDeal call below — keeps via-ir stack scheduling within budget.
{
// Get company name from the parent CyberCorp
string memory companyName = ICyberCorp(LexScrowStorage.getCorp()).cyberCORPName();
for (uint256 i = 0; i < _certData.length; i++) {
certPrinterAddress[i] = DealManagerStorage.getIssuanceManager().createCertPrinter(
_certData[i].defaultLegend,
string.concat(companyName, " ", _certData[i].name),
_certData[i].symbol,
_certData[i].uri,
_certData[i].securityClass,
_certData[i].securitySeries,
_certData[i].extension,
_certData[i].seriesData
);
}
}
// Create and sign deal
certIds = new uint256[](certPrinterAddress.length);
(id, certIds) = proposeAndSignDeal(
certPrinterAddress,
stableAddress,
_paymentAmount,
_templateId,
salt,
_globalValues,
_parties,
_details,
msg.sender,
signature,
_partyValues,
conditions,
secretHash,
expiry
);
}
/// @notice Compute the primary issuance fee based on ticket size
/// @dev Currently the factory owner (MetaLeX) unilaterally set the fee ratio;
/// in the future, it could be determined through a governance process.
/// Secondary trades are priced apart, from the factory's secondary rate.
/// @return Fee amount
function computeFee(uint256 size) public view returns (uint256) {
return size * IDealManagerFactory(DealManagerStorage.getUpgradeFactory()).getDefaultFeeRatio() / DealManagerFactoryStorage.BASIS_POINTS;
}
/// @notice Gets the payable address for the fees
/// @dev The factory owner (MetaLeX) unilaterally set the payable address
/// @return Payable address for the fees
function getPlatformPayable() public view returns (address) {
return IDealManagerFactory(DealManagerStorage.getUpgradeFactory()).getPlatformPayable();
}
// ─────────────────────────────────────────────────────────────────────────
// LexScrowStorage surface — thin wrappers (LexScrowStorage is now a library) so the proxy keeps
// exposing these selectors for off-chain callers and condition contracts (ILexScrowStorage).
// ─────────────────────────────────────────────────────────────────────────
/// @notice Get escrow details for a given agreement id
function getEscrowDetails(bytes32 agreementId) public view returns (Escrow memory) {
return LexScrowStorage.getEscrow(agreementId);
}
/// @notice Check all conditions attached to the escrow for the given agreement
function conditionCheck(bytes32 agreementId) public view returns (bool) {
return LexScrowStorage.conditionCheck(agreementId);
}
/// @notice ERC721 receiver hook for safe transfers into escrow (moved here from LexScrowStorage)
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
return this.onERC721Received.selector;
}
/// @notice ERC1155 receiver hook for safe transfers into escrow (moved here from LexScrowStorage)
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) {
return this.onERC1155Received.selector;
}
// ─────────────────────────────────────────────────────────────────────────
// Secondary trade — threshold setters
// ─────────────────────────────────────────────────────────────────────────
function setMinTradeThreshold(uint256 units, uint256 consideration) external onlyAdmin {
SecondaryTradeStorage.SecondaryTradeData storage ds = SecondaryTradeStorage.secondaryTradeStorage();
ds.minTradeUnits = units;
ds.minTradeConsideration = consideration;
emit MinTradeThresholdSet(units, consideration, msg.sender);
}
function setSettlementWindow(uint256 window) external onlyAdmin {
SecondaryTradeStorage.secondaryTradeStorage().settlementWindow = window;
emit SettlementWindowSet(window, msg.sender);
}
function setDefaultIntegrator(address integrator) external onlyAdmin {
if (integrator != address(0)) {
if (!IDealManagerFactory(DealManagerStorage.getUpgradeFactory()).isIntegratorWhitelisted(integrator))
revert IntegratorNotWhitelisted();
}
SecondaryTradeStorage.SecondaryTradeData storage ds = SecondaryTradeStorage.secondaryTradeStorage();
address oldIntegrator = ds.defaultIntegrator;
ds.defaultIntegrator = integrator;
emit DefaultIntegratorSet(integrator, oldIntegrator, msg.sender);
}
// ─────────────────────────────────────────────────────────────────────────
// Secondary trade — condition config (owner-managed; read live at every post/accept/finalize)
// ─────────────────────────────────────────────────────────────────────────
// Each layer is set as a whole list, so one entry point per layer covers add, remove and reorder.
// Layer 2 — fund-specific (§6) threshold conditions (apply to every offer)
function setSpvThresholdConditions(address[] calldata conditions) external onlyAdmin {
SecondaryTradeStorage.setSpvThresholdConditions(conditions);
}
/// @notice Layer 1 — exemption-specific (§5) conditions for `pathway`, plus whether this SPV supports
/// it. A pathway that is not enabled can be neither pinned nor elected.
function setPathwayThresholdConditions(ExemptionPathway pathway, address[] calldata conditions, bool enabled)
external
onlyAdmin
{
SecondaryTradeStorage.setPathwayThresholdConditions(pathway, conditions, enabled);
}
// Closing conditions (apply to every offer; evaluated at finalize)
function setClosingConditions(address[] calldata conditions) external onlyAdmin {
SecondaryTradeStorage.setClosingConditions(conditions);
}
function getSpvThresholdConditions() external view returns (address[] memory) {
return SecondaryTradeStorage.secondaryTradeStorage().spvThresholdConditions;
}
function getPathwayThresholdConditions(ExemptionPathway pathway) external view returns (address[] memory) {
return SecondaryTradeStorage.secondaryTradeStorage().pathwayThresholdConditions[pathway];
}
function isPathwayEnabled(ExemptionPathway pathway) external view returns (bool) {
return SecondaryTradeStorage.secondaryTradeStorage().pathwayEnabled[pathway];
}
function getClosingConditions() external view returns (address[] memory) {
return SecondaryTradeStorage.secondaryTradeStorage().closingConditions;
}
function getMinTradeThreshold() external view returns (uint256 units, uint256 consideration) {
SecondaryTradeStorage.SecondaryTradeData storage ds = SecondaryTradeStorage.secondaryTradeStorage();
return (ds.minTradeUnits, ds.minTradeConsideration);
}
function getDefaultIntegrator() external view returns (address) {
return SecondaryTradeStorage.secondaryTradeStorage().defaultIntegrator;
}
/// @notice Effective settlement window (applies the default when unset).
function getSettlementWindow() external view returns (uint256) {
return SecondaryTradeStorage.getSettlementWindow();
}
function getOffer(bytes32 offerId) external view returns (Offer memory) {
return SecondaryTradeStorage.secondaryTradeStorage().offers[offerId];
}
function getSecondaryEscrow(bytes32 agreementId) external view returns (SecondaryEscrow memory) {
return SecondaryTradeStorage.secondaryTradeStorage().escrows[agreementId];
}
// ─────────────────────────────────────────────────────────────────────────
// Secondary trade — offer lifecycle
// ─────────────────────────────────────────────────────────────────────────
/// @notice Posts a secondary-trade offer on behalf of `forAddr` (relayer path). `sig` is `forAddr`'s
/// EIP-712 authorization over `params` + `forAddr` + `nonce`. Thin wrapper over the linked logic.
function postOffer(PostOfferParams calldata params, address forAddr, uint256 nonce, bytes memory sig) external nonReentrant returns (bytes32 offerId) {
return SecondaryTradeStorage.postOffer(params, forAddr, nonce, sig);
}
/// @notice Posts a secondary-trade offer. Thin wrapper over the linked SecondaryTradeStorage logic.
function postOffer(PostOfferParams calldata params) external nonReentrant returns (bytes32 offerId) {
return SecondaryTradeStorage.postOffer(params);
}
/// @notice Cancels a secondary-trade offer on behalf of `forAddr` (relayer path). `sig` is `forAddr`'s
/// EIP-712 authorization over `offerId` + `forAddr` + `nonce`. Thin wrapper over the linked logic.
function cancelOffer(bytes32 offerId, address forAddr, uint256 nonce, bytes memory sig) external nonReentrant {
return SecondaryTradeStorage.cancelOffer(offerId, forAddr, nonce, sig);
}
/// @notice Cancels a non-terminal offer and returns its uncommitted assets to the offeror
/// @dev Only the free pool (uncommitted units / consideration) is refunded/released. Settlements already
/// accepted stay ACCEPTED and resolve on their own — finalized normally, or voided via the two-party
/// voidSecondaryTradeAgreement / expiry path; their assets stay in DealManager custody until then.
/// @param offerId Offer to cancel
function cancelOffer(bytes32 offerId) external nonReentrant {
SecondaryTradeStorage.cancelOffer(offerId);
}
/// @notice Accepts a secondary-trade offer on behalf of `forAddr` (relayer path). `sig` is `forAddr`'s
/// EIP-712 authorization over `params` + `forAddr` + `nonce`. Thin wrapper over the linked logic.
function acceptOffer(AcceptOfferParams calldata params, address forAddr, uint256 nonce, bytes memory sig) external nonReentrant returns (bytes32 settlementAgreementId) {
return SecondaryTradeStorage.acceptOffer(params, forAddr, nonce, sig);
}
/// @notice Accepts (fully or partially) a secondary-trade offer. Thin wrapper over the linked logic.
function acceptOffer(AcceptOfferParams calldata params) external nonReentrant returns (bytes32 settlementAgreementId) {
return SecondaryTradeStorage.acceptOffer(params);
}
/// @notice Finalizes an accepted secondary-trade settlement. Thin wrapper over the linked logic.
/// @dev Secondary counterpart of finalizeDeal; the two paths are kept fully separate.
function finalizeSecondaryTradeAgreement(bytes32 agreementId) external nonReentrant {
SecondaryTradeStorage.finalizeSecondaryTradeAgreement(agreementId);
}
/// @notice Voids an expired secondary-trade settlement. Thin wrapper over the linked logic.
/// @dev Secondary counterpart of voidExpiredDeal; the two paths are kept fully separate.
function voidExpiredSecondaryTradeAgreement(bytes32 agreementId, address signer, bytes memory signature) external nonReentrant {
SecondaryTradeStorage.voidExpiredSecondaryTradeAgreement(agreementId, signer, signature);
}
/// @notice Records a party's request to void an ACCEPTED secondary settlement before it is finalized or expires
/// @dev Finalizer-vouched request channel: the registry voids the agreement only once BOTH parties have
/// requested (or it is past expiry). The local escrow is settled only when that actually happens, keeping
/// DealManager and the registry in sync; a lone request just records intent and the counterparty can still finalize.
/// @param agreementId Settlement agreement to void
/// @param signer Caller's address (must equal msg.sender)
/// @param signature Caller's EIP-712 void signature, forwarded to the agreement registry
function voidSecondaryTradeAgreement(bytes32 agreementId, address signer, bytes memory signature) external nonReentrant {
SecondaryTradeStorage.voidSecondaryTradeAgreement(agreementId, signer, signature);
}
/// @notice Relayer variant of voidSecondaryTradeAgreement: a relayer submits `signer`'s void request on
/// their behalf, authorized by `signer`'s EIP-712 signature over the request plus an unordered `nonce`.
function voidSecondaryTradeAgreement(bytes32 agreementId, address signer, bytes memory signature, uint256 nonce, bytes memory authSig) external nonReentrant {
SecondaryTradeStorage.voidSecondaryTradeAgreement(agreementId, signer, signature, nonce, authSig);
}
/// @notice Syncs a secondary settlement that was voided directly in the agreement registry
/// @dev Callable by anyone; guards against double-void via the terminal-state checks
/// @param agreementId Settlement agreement that was already voided in the registry
function syncVoidedSecondaryTradeAgreement(bytes32 agreementId) external nonReentrant {
SecondaryTradeStorage.syncVoidedSecondaryTradeAgreement(agreementId);
}
/// @notice UUPS upgrade authorization
/// @dev MetaLeX releases new versions through the factory's reference implementation,
/// and the CyberCorp owner can decide if or when he wants to perform the upgrade
function _authorizeUpgrade(
address newImplementation
) internal override onlyOwner {
if(IDealManagerFactory(DealManagerStorage.getUpgradeFactory()).getRefImplementation() != newImplementation) {
revert NotRefImplementation();
}
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {
"src/CyberAgreementRegistry.sol": {
"CyberAgreementJson": "0x7ccD9CF37B17b1433df67724B18C5c3dF7ec9e8E",
"CyberAgreementBound": "0xe8788a560F68a497C23cddCAFA4728B175e93415"
},
"src/storage/LexScrowStorage.sol": {
"LexScrowStorage": "0xe06006dDcC4ff20aacff20906F56d9893124d49D"
},
"src/creds/LeXcheXBadgeRender.sol": {
"LeXcheXBadgeRender": "0xB62cEBD990aAD2114Ef5120536b38Ce7ef5C99a2"
},
"src/storage/DealManagerStorage.sol": {
"DealManagerStorage": "0x17454BE928Bf061678A2E1D7909A94E6AbAEE644"
},
"src/storage/RoundManagerStorage.sol": {
"RoundManagerStorage": "0xFDb8ED7631Ed803E6110c07f2926AbA088AA3813"
},
"src/storage/SecondaryTradeStorage.sol": {
"SecondaryTradeStorage": "0xE65839Cf4d81aF8D8aB30a59558bF249E3520e86"
},
"src/CertificateImageContentBuilder.sol": {
"CertificateImageContentBuilder": "0xf73cF11Dc03473e53582137fB336A06C22eb4c1D"
},
"src/storage/IssuanceManagerStorage.sol": {
"IssuanceManagerStorage": "0xbC2878B5777B33B951260A6ff866933063e1220c"
},
"src/storage/LedgerEntryTokenStorage.sol": {
"LedgerEntryTokenStorage": "0xe720A5d00732830df878629cEdE70B2bF95c4a05"
},
"src/storage/extensions/ShareCertDataLayerLib.sol": {
"ShareCertDataLayerLib": "0x780211CDcf92273C00a29bE6cD367c4abc70468c"
}
},
"optimizer": {
"runs": 15,
"enabled": true
},
"evmVersion": "prague",
"remappings": [
"openzeppelin-contracts/=dependencies/openzeppelin-contracts/contracts/",
"openzeppelin-contracts-upgradeable/=dependencies/openzeppelin-contracts-upgradeable/contracts/",
"erc721a/=dependencies/erc721a-4.3.0/",
"forge-std/=dependencies/forge-std/src/",
"ConditionManager/=dependencies/ConditionManager/src/",
"dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:erc4626-tests/=dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/erc4626-tests/",
"dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:erc4626-tests/=dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/erc4626-tests/",
"dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=dependencies/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"dependencies/openzeppelin-contracts-upgradeable/:erc4626-tests/=dependencies/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"dependencies/openzeppelin-contracts-upgradeable/:erc4626-tests/=dependencies/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"dependencies/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=dependencies/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"dependencies/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=dependencies/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"dependencies/openzeppelin-contracts/:erc4626-tests/=dependencies/openzeppelin-contracts/lib/erc4626-tests/",
"dependencies/openzeppelin-contracts/:erc4626-tests/=dependencies/openzeppelin-contracts/lib/erc4626-tests/",
"dependencies/openzeppelin-contracts/:halmos-cheatcodes/=dependencies/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"dependencies/openzeppelin-contracts/:halmos-cheatcodes/=dependencies/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"@openzeppelin/contracts-upgradeable/=dependencies/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=dependencies/openzeppelin-contracts/contracts/",
"erc4626-tests/=dependencies/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=dependencies/openzeppelin-contracts/lib/halmos-cheatcodes/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.