Skip to content

Commit

Permalink
fix: type mispelling
Browse files Browse the repository at this point in the history
  • Loading branch information
geolffreym committed Dec 21, 2024
1 parent 489920b commit b0c6d76
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 13 deletions.
18 changes: 14 additions & 4 deletions contracts/financial/AgreementManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,21 @@ contract AgreementManager is Initializable, UUPSUpgradeable, AccessControlledUpg
revert InvalidAgreementOp("Agreement must include at least one party");
}

// agreements transport value..
// imagine an agreement like a bonus, gift card, prepaid card or check..
// IMPORTANT:
// Agreements transport value and represent a defined commitment between parties.
// Think of an agreement as similar to a bonus, gift card, prepaid card, or check:
// its value and terms are fixed at creation and cannot be changed arbitrarily.

// Fees are calculated during this preview and "frozen" into the agreement terms.
// This ensures that the fee structure at the time of agreement creation remains
// immutable and protects all parties from potential future manipulations.
//
// By locking in fees during agreement creation, the protocol avoids scenarios
// where fee structures change (favorably or unfavorably) after creation,
// which could lead to abuse or exploitation.
uint256 deductions = _calcFees(amount, currency);
// this design protects the agreement's terms from any future changes in fees or protocol conditions.
// by using this immutable approach, the agreement terms are "frozen" at the time of creation.
// This design ensures fairness and transparency by preventing any future
// adjustments to fees or protocol conditions from affecting the terms of this agreement.
return
T.Agreement({
broker: broker, // the authorized account to manage the agreement
Expand Down
14 changes: 13 additions & 1 deletion contracts/financial/AgreementSettler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,19 @@ contract AgreementSettler is
revert InvalidAgreementOp("Only initiator can quit the agreement.");
}

// a partial rollback amount is registered in vault..
// IMPORTANT:
// The protocol enforces a penalty for quitting the agreement to ensure fairness
// and discourage frivolous cancellations. This mechanism protects the integrity
// of the agreement process and ensures that resources spent in its creation
// (e.g., computation, storage, and fee management) are compensated.
//
// Fees are immutable and determined at the time of agreement creation
// (as defined in `previewAgreement`).This design disincentives manipulation,
// ensuring that no changes can occur later to unfairly benefit or harm the initiator or other parties involved.

//
// Penalty fees retained here also help maintain the protocol's economic balance
// and ensure that the system operates sustainably over time.
uint256 fees = agreement.fees; // keep fees as penalty
uint256 available = agreement.total - fees; // initiator rollback
address initiator = agreement.initiator; // the original initiator
Expand Down
6 changes: 3 additions & 3 deletions contracts/rights/RightsAssetCustodian.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract RightsAssetCustodian is Initializable, UUPSUpgradeable, AccessControlle
/// The random number is generated using the block hash and the holder's address, and is used to determine
/// which custodian is selected.
/// @param holder The address of the asset rights holder whose custodian is to be selected.
function getBalancedCustodian(address holder) public view returns (address choosen) {
function getBalancedCustodian(address holder) public view returns (address chosen) {
uint256 i = 0;
uint256 acc = 0;
bytes32 blockHash = blockhash(block.number - 1);
Expand All @@ -121,7 +121,7 @@ contract RightsAssetCustodian is Initializable, UUPSUpgradeable, AccessControlle
// This ensures that no more redundancy than allowed is used,
// even if more custodians are available.
n = _maxDistributionRedundancy <= n ? _maxDistributionRedundancy : n;
// arithmetic sucesion
// arithmetic succession
// eg: 3 = 1+2+3 = n(n+1) / 2 = 6
uint256 s = (n * (n + 1)) / 2;

Expand All @@ -143,7 +143,7 @@ contract RightsAssetCustodian is Initializable, UUPSUpgradeable, AccessControlle
acc += ((n - i) * C.BPS_MAX) / s;
address candidate = _custodiansByHolder[holder].at(i);
if (acc >= random && _isValidActiveDistributor(candidate)) {
choosen = candidate;
chosen = candidate;
}

// i can't overflow n
Expand Down
28 changes: 23 additions & 5 deletions contracts/syndication/DistributorReferendum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,23 @@ contract DistributorReferendum is
/// @param distributor The address of the distributor to register.
/// @param currency The currency used to pay enrollment.
function register(address distributor, address currency) external onlyValidDistributor(distributor) {
// !IMPORTANT if fees manager does not support the currency, will revert..
// !IMPORTANT:
// Fees act as a mechanism to prevent abuse or spam by users
// when submitting distributors for approval. This discourages users from
// making frivolous or excessive registrations without genuine intent.
//
// Additionally, the fees establish a foundation of real interest and commitment
// from the distributor. This ensures that only those who see value in the protocol
// and are willing to contribute to its ecosystem will participate.
//
// The collected fees are used to support the protocol's operations, aligning
// individual actions with the broader sustainability of the network.
// !IMPORTANT If fees manager does not support the currency, will revert..
uint256 fees = TOLLGATE.getFees(T.Context.SYN, currency);
VAULT.lock(msg.sender, fees, currency); // lock funds for distributor
VAULT.claim(msg.sender, fees, currency); // claim the funds on behalf referendum
VAULT.claim(msg.sender, fees, currency); // claim the funds on behalf referendum
VAULT.withdraw(address(this), fees, currency); // transfer the funds to referendum

// register distributor as pending approval
_register(uint160(distributor));
// set the distributor active enrollment period..
Expand Down Expand Up @@ -160,8 +171,15 @@ contract DistributorReferendum is
/// @param distributor The distributor's address to check.
function isActive(address distributor) public view onlyValidDistributor(distributor) returns (bool) {
// TODO a renovation mechanism is needed to update the enrollment time
// this mechanisms helps to verify the availability of the distributor forcing recurrent registrations.
return _status(uint160(distributor)) == Status.Active && _enrollmentDeadline[distributor] > block.timestamp;
/// It ensures that distributors remain engaged and do not become inactive for extended periods.
/// The enrollment deadline enforces a time-based mechanism where distributors must renew
/// their registration to maintain their active status. This prevents dormant distributors
/// from continuing to benefit from the protocol without contributing.

// This mechanism helps to verify the availability of the distributor,
// forcing recurrent registrations and ensuring ongoing participation.
bool notExpiredDeadline = _enrollmentDeadline[distributor] > block.timestamp;
return _status(uint160(distributor)) == Status.Active && notExpiredDeadline;
}

/// @notice Checks if the entity is waiting.
Expand Down

0 comments on commit b0c6d76

Please sign in to comment.