Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,814 changes: 1,814 additions & 0 deletions packages/ats/contracts/IMPLEMENTATION_PLAN_ORCHESTRATOR.md

Large diffs are not rendered by default.

445 changes: 445 additions & 0 deletions packages/ats/contracts/STORAGE_ENCAPSULATION_VIOLATIONS.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ pragma solidity >=0.8.0 <0.9.0;

import { IBondRead } from "./IBondRead.sol";
interface IBond {
// Events from IERC1410 that are emitted by this facet
event RedeemedByPartition(
bytes32 indexed partition,
address indexed from,
address indexed to,
uint256 value,
bytes data
);

/**
* @notice Emitted when a coupon is created or updated for a bond or corporate action.
* @param corporateActionId Unique identifier grouping related corporate actions or coupons.
Expand Down Expand Up @@ -53,4 +62,4 @@ interface IBond {
* @param _maturityDate The new maturity date to be set.
*/
function updateMaturityDate(uint256 _maturityDate) external returns (bool success_);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity >=0.8.0 <0.9.0;

import { ScheduledCrossOrderedTasks } from "../ScheduledCrossOrderedTasks.sol";
import { IBondRead } from "../../../interfaces/bond/IBondRead.sol";
import { IKpiLinkedRate } from "../../../interfaces/interestRates/kpiLinkedRate/IKpiLinkedRate.sol";
import { LibBond } from "../../../../../lib/domain/LibBond.sol";
import { LibInterestRate } from "../../../../../lib/domain/LibInterestRate.sol";
import { LibKpis } from "../../../../../lib/domain/LibKpis.sol";
import { LibProceedRecipients } from "../../../../../lib/domain/LibProceedRecipients.sol";
import { KpiLinkedRateDataStorage } from "../../../../../storage/ScheduledStorage.sol";

abstract contract ScheduledCrossOrderedTasksKpiLinkedRate is ScheduledCrossOrderedTasks {
/// @notice Calculate and store the KPI-linked interest rate when a coupon is listed
Expand All @@ -19,10 +19,10 @@ abstract contract ScheduledCrossOrderedTasksKpiLinkedRate is ScheduledCrossOrder
if (coupon.rateStatus == IBondRead.RateCalculationStatus.SET) return;
if (coupon.fixingDate > _timestamp) return;

KpiLinkedRateDataStorage storage kpiRateStorage = LibInterestRate.getKpiLinkedRate();
IKpiLinkedRate.InterestRate memory kpiInterestRate = LibInterestRate.getKpiLinkedInterestRate();

if (coupon.fixingDate < kpiRateStorage.startPeriod) {
LibBond.updateCouponRate(_couponID, coupon, kpiRateStorage.startRate, kpiRateStorage.rateDecimals);
if (coupon.fixingDate < kpiInterestRate.startPeriod) {
LibBond.updateCouponRate(_couponID, coupon, kpiInterestRate.startRate, kpiInterestRate.rateDecimals);
return;
}

Expand All @@ -36,7 +36,7 @@ abstract contract ScheduledCrossOrderedTasksKpiLinkedRate is ScheduledCrossOrder

for (uint256 i = 0; i < projects.length; ) {
(uint256 value, bool exists) = LibKpis.getLatestKpiData(
coupon.fixingDate - kpiRateStorage.reportPeriod,
coupon.fixingDate - kpiInterestRate.reportPeriod,
coupon.fixingDate,
projects[i]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { LibBond } from "../../../../../lib/domain/LibBond.sol";
import { LibInterestRate } from "../../../../../lib/domain/LibInterestRate.sol";
import { LibKpis } from "../../../../../lib/domain/LibKpis.sol";
import { LibProceedRecipients } from "../../../../../lib/domain/LibProceedRecipients.sol";
import { SustainabilityPerformanceTargetRateDataStorage } from "../../../../../storage/ScheduledStorage.sol";

abstract contract ScheduledCrossOrderedTasksSustainabilityPerformanceTargetRate is ScheduledCrossOrderedTasks {
/// @notice Calculate and store the sustainability rate when a coupon is listed
Expand All @@ -22,10 +21,10 @@ abstract contract ScheduledCrossOrderedTasksSustainabilityPerformanceTargetRate
if (coupon.rateStatus == IBondRead.RateCalculationStatus.SET) return;
if (coupon.fixingDate > _timestamp) return;

SustainabilityPerformanceTargetRateDataStorage storage sptRateStorage = LibInterestRate.getSustainabilityRate();
ISustainabilityPerformanceTargetRate.InterestRate memory sptInterestRate = LibInterestRate.getSustainabilityInterestRate();

if (coupon.fixingDate < sptRateStorage.startPeriod) {
LibBond.updateCouponRate(_couponID, coupon, sptRateStorage.startRate, sptRateStorage.rateDecimals);
if (coupon.fixingDate < sptInterestRate.startPeriod) {
LibBond.updateCouponRate(_couponID, coupon, sptInterestRate.startRate, sptInterestRate.rateDecimals);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LibAccess } from "../../../../lib/core/LibAccess.sol";
import { LibCompliance } from "../../../../lib/core/LibCompliance.sol";
import { LibERC1410 } from "../../../../lib/domain/LibERC1410.sol";
import { LibERC1594 } from "../../../../lib/domain/LibERC1594.sol";
import { LibTokenTransfer } from "../../../../lib/orchestrator/LibTokenTransfer.sol";
import { TokenCoreOps } from "../../../../lib/orchestrator/TokenCoreOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";
import { _ISSUER_ROLE, _AGENT_ROLE } from "../../../../constants/roles.sol";

Expand All @@ -33,6 +33,6 @@ abstract contract ERC1410Issuer is IERC1410Issuer, IControlListBase {
LibAccess.checkAnyRole(roles, msg.sender);
LibCompliance.requireNotRecovered(msg.sender);
}
LibTokenTransfer.issueByPartition(_issueData, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.issueByPartition(_issueData, LibTimeTravel.getBlockTimestamp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LibProtectedPartitions } from "../../../../lib/core/LibProtectedPartiti
import { LibNonce } from "../../../../lib/core/LibNonce.sol";
import { LibResolverProxy } from "../../../../infrastructure/proxy/LibResolverProxy.sol";
import { LibERC20 } from "../../../../lib/domain/LibERC20.sol";
import { LibTokenTransfer } from "../../../../lib/orchestrator/LibTokenTransfer.sol";
import { TokenCoreOps } from "../../../../lib/orchestrator/TokenCoreOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";
import { checkNounceAndDeadline } from "../../../../lib/core/ERC712.sol";
import { _CONTROLLER_ROLE, _AGENT_ROLE } from "../../../../constants/roles.sol";
Expand Down Expand Up @@ -47,7 +47,7 @@ abstract contract ERC1410Management is IERC1410Management, IControlListBase, IER
LibAccess.checkAnyRole(roles, msg.sender);
}
return
LibTokenTransfer.transferByPartition(
TokenCoreOps.transferByPartition(
_from,
BasicTransferInfo(_to, _value),
_partition,
Expand All @@ -74,7 +74,7 @@ abstract contract ERC1410Management is IERC1410Management, IControlListBase, IER
roles[1] = _AGENT_ROLE;
LibAccess.checkAnyRole(roles, msg.sender);
}
LibTokenTransfer.redeemByPartition(
TokenCoreOps.redeemByPartition(
_partition,
_tokenHolder,
msg.sender,
Expand All @@ -101,7 +101,7 @@ abstract contract ERC1410Management is IERC1410Management, IControlListBase, IER
LibTimeTravel.getBlockTimestamp()
);
return
LibTokenTransfer.transferByPartition(
TokenCoreOps.transferByPartition(
_operatorTransferData.from,
BasicTransferInfo(_operatorTransferData.to, _operatorTransferData.value),
_operatorTransferData.partition,
Expand Down Expand Up @@ -129,7 +129,7 @@ abstract contract ERC1410Management is IERC1410Management, IControlListBase, IER
_value,
LibTimeTravel.getBlockTimestamp()
);
LibTokenTransfer.redeemByPartition(
TokenCoreOps.redeemByPartition(
_partition,
_tokenHolder,
msg.sender,
Expand Down Expand Up @@ -177,7 +177,7 @@ abstract contract ERC1410Management is IERC1410Management, IControlListBase, IER
);
LibNonce.setNonceFor(_protectionData.nounce, _from);
return
LibTokenTransfer.transferByPartition(
TokenCoreOps.transferByPartition(
_from,
BasicTransferInfo(_to, _amount),
_partition,
Expand Down Expand Up @@ -221,7 +221,7 @@ abstract contract ERC1410Management is IERC1410Management, IControlListBase, IER
address(this)
);
LibNonce.setNonceFor(_protectionData.nounce, _from);
LibTokenTransfer.redeemByPartition(
TokenCoreOps.redeemByPartition(
_partition,
_from,
msg.sender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LibERC1410 } from "../../../../lib/domain/LibERC1410.sol";
import { LibERC1594 } from "../../../../lib/domain/LibERC1594.sol";
import { LibProtectedPartitions } from "../../../../lib/core/LibProtectedPartitions.sol";
import { LibABAF } from "../../../../lib/domain/LibABAF.sol";
import { LibTokenTransfer } from "../../../../lib/orchestrator/LibTokenTransfer.sol";
import { TokenCoreOps } from "../../../../lib/orchestrator/TokenCoreOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";

abstract contract ERC1410TokenHolder is IERC1410TokenHolder, IControlListBase {
Expand All @@ -29,7 +29,7 @@ abstract contract ERC1410TokenHolder is IERC1410TokenHolder, IControlListBase {
LibTimeTravel.getBlockTimestamp()
);
return
LibTokenTransfer.transferByPartition(
TokenCoreOps.transferByPartition(
msg.sender,
_basicTransferInfo,
_partition,
Expand All @@ -50,7 +50,7 @@ abstract contract ERC1410TokenHolder is IERC1410TokenHolder, IControlListBase {
_value,
LibTimeTravel.getBlockTimestamp()
);
LibTokenTransfer.redeemByPartition(
TokenCoreOps.redeemByPartition(
_partition,
msg.sender,
address(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { LibAccess } from "../../../../lib/core/LibAccess.sol";
import { LibCap } from "../../../../lib/core/LibCap.sol";
import { LibCompliance } from "../../../../lib/core/LibCompliance.sol";
import { LibProtectedPartitions } from "../../../../lib/core/LibProtectedPartitions.sol";
import { LibTokenTransfer } from "../../../../lib/orchestrator/LibTokenTransfer.sol";
import { TokenCoreOps } from "../../../../lib/orchestrator/TokenCoreOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";
import { _ISSUER_ROLE, _AGENT_ROLE } from "../../../../constants/roles.sol";
import { _DEFAULT_PARTITION } from "../../../../constants/values.sol";
Expand Down Expand Up @@ -41,7 +41,7 @@ abstract contract ERC1594 is IERC1594, IControlListBase, IERC1644Base {
_value,
LibTimeTravel.getBlockTimestamp()
);
LibTokenTransfer.transfer(msg.sender, _to, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.transfer(msg.sender, _to, _value, LibTimeTravel.getBlockTimestamp());
emit TransferWithData(msg.sender, _to, _value, _data);
}

Expand All @@ -59,7 +59,7 @@ abstract contract ERC1594 is IERC1594, IControlListBase, IERC1644Base {
LibCompliance.requireNotRecovered(msg.sender);
LibCompliance.requireNotRecovered(_to);
LibCompliance.requireNotRecovered(_from);
LibTokenTransfer.transferFrom(msg.sender, _from, _to, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.transferFrom(msg.sender, _from, _to, _value, LibTimeTravel.getBlockTimestamp());
emit TransferFromWithData(msg.sender, _from, _to, _value, _data);
}

Expand All @@ -75,7 +75,7 @@ abstract contract ERC1594 is IERC1594, IControlListBase, IERC1644Base {
roles[1] = _AGENT_ROLE;
LibAccess.checkAnyRole(roles, msg.sender);
}
LibTokenTransfer.mint(_tokenHolder, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.mint(_tokenHolder, _value, LibTimeTravel.getBlockTimestamp());
emit IERC1594.Issued(msg.sender, _tokenHolder, _value, _data);
}

Expand All @@ -89,7 +89,7 @@ abstract contract ERC1594 is IERC1594, IControlListBase, IERC1644Base {
_value,
LibTimeTravel.getBlockTimestamp()
);
LibTokenTransfer.burn(msg.sender, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.burn(msg.sender, _value, LibTimeTravel.getBlockTimestamp());
emit IERC1594.Redeemed(address(0), msg.sender, _value, _data);
}

Expand All @@ -105,8 +105,8 @@ abstract contract ERC1594 is IERC1594, IControlListBase, IERC1644Base {
);
LibCompliance.requireNotRecovered(msg.sender);
LibCompliance.requireNotRecovered(_tokenHolder);
LibTokenTransfer.decreaseAllowedBalance(_tokenHolder, msg.sender, _value);
LibTokenTransfer.burn(_tokenHolder, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.decreaseAllowedBalance(_tokenHolder, msg.sender, _value);
TokenCoreOps.burn(_tokenHolder, _value, LibTimeTravel.getBlockTimestamp());
emit IERC1594.Redeemed(msg.sender, _tokenHolder, _value, _data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LibPause } from "../../../../lib/core/LibPause.sol";
import { LibAccess } from "../../../../lib/core/LibAccess.sol";
import { LibERC1410 } from "../../../../lib/domain/LibERC1410.sol";
import { LibERC1644 } from "../../../../lib/domain/LibERC1644.sol";
import { LibTokenTransfer } from "../../../../lib/orchestrator/LibTokenTransfer.sol";
import { TokenCoreOps } from "../../../../lib/orchestrator/TokenCoreOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";
import { _DEFAULT_ADMIN_ROLE, _CONTROLLER_ROLE, _AGENT_ROLE } from "../../../../constants/roles.sol";

Expand Down Expand Up @@ -37,7 +37,7 @@ abstract contract ERC1644 is IERC1644, IControlListBase {
roles[1] = _AGENT_ROLE;
LibAccess.checkAnyRole(roles, msg.sender);
}
LibTokenTransfer.transfer(_from, _to, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.transfer(_from, _to, _value, LibTimeTravel.getBlockTimestamp());
emit IERC1644Base.ControllerTransfer(msg.sender, _from, _to, _value, _data, _operatorData);
}

Expand All @@ -56,7 +56,7 @@ abstract contract ERC1644 is IERC1644, IControlListBase {
roles[1] = _AGENT_ROLE;
LibAccess.checkAnyRole(roles, msg.sender);
}
LibTokenTransfer.burn(_tokenHolder, _value, LibTimeTravel.getBlockTimestamp());
TokenCoreOps.burn(_tokenHolder, _value, LibTimeTravel.getBlockTimestamp());
emit IERC1644Base.ControllerRedemption(msg.sender, _tokenHolder, _value, _data, _operatorData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LibABAF } from "../../../../lib/domain/LibABAF.sol";
import { LibERC1594 } from "../../../../lib/domain/LibERC1594.sol";
import { LibCompliance } from "../../../../lib/core/LibCompliance.sol";
import { LibProtectedPartitions } from "../../../../lib/core/LibProtectedPartitions.sol";
import { LibTokenTransfer } from "../../../../lib/orchestrator/LibTokenTransfer.sol";
import { TokenCoreOps } from "../../../../lib/orchestrator/TokenCoreOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";
import { IControlListBase } from "../../interfaces/controlList/IControlListBase.sol";
import { _DEFAULT_PARTITION } from "../../../../constants/values.sol";
Expand All @@ -34,7 +34,7 @@ abstract contract ERC20 is IERC20, IControlListBase {
LibCompliance.requireNotRecovered(msg.sender);
LibCompliance.requireNotRecovered(spender);
LibERC1410.checkWithoutMultiPartition();
return LibTokenTransfer.approve(msg.sender, spender, value);
return TokenCoreOps.approve(msg.sender, spender, value);
}

function transfer(address to, uint256 amount) external override returns (bool) {
Expand All @@ -48,7 +48,7 @@ abstract contract ERC20 is IERC20, IControlListBase {
amount,
LibTimeTravel.getBlockTimestamp()
);
return LibTokenTransfer.transfer(msg.sender, to, amount, LibTimeTravel.getBlockTimestamp());
return TokenCoreOps.transfer(msg.sender, to, amount, LibTimeTravel.getBlockTimestamp());
}

function transferFrom(address from, address to, uint256 amount) external override returns (bool) {
Expand All @@ -62,21 +62,21 @@ abstract contract ERC20 is IERC20, IControlListBase {
amount,
LibTimeTravel.getBlockTimestamp()
);
return LibTokenTransfer.transferFrom(msg.sender, from, to, amount, LibTimeTravel.getBlockTimestamp());
return TokenCoreOps.transferFrom(msg.sender, from, to, amount, LibTimeTravel.getBlockTimestamp());
}

function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
LibPause.requireNotPaused();
LibERC1594.checkCompliance(msg.sender, msg.sender, spender, false);
LibERC1410.checkWithoutMultiPartition();
return LibTokenTransfer.increaseAllowance(msg.sender, spender, addedValue);
return TokenCoreOps.increaseAllowance(msg.sender, spender, addedValue);
}

function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
LibPause.requireNotPaused();
LibERC1410.checkWithoutMultiPartition();
LibERC1594.checkCompliance(msg.sender, msg.sender, spender, false);
return LibTokenTransfer.decreaseAllowance(msg.sender, spender, subtractedValue);
return TokenCoreOps.decreaseAllowance(msg.sender, spender, subtractedValue);
}

// ════════════════════════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { LibPause } from "../../../../lib/core/LibPause.sol";
import { LibERC20Votes } from "../../../../lib/domain/LibERC20Votes.sol";
import { LibABAF } from "../../../../lib/domain/LibABAF.sol";
import { LibTotalBalance } from "../../../../lib/orchestrator/LibTotalBalance.sol";
import { HoldOps } from "../../../../lib/orchestrator/HoldOps.sol";
import { LibTimeTravel } from "../../../../test/timeTravel/LibTimeTravel.sol";

abstract contract ERC20Votes is IERC20Votes {
Expand All @@ -37,7 +37,7 @@ abstract contract ERC20Votes is IERC20Votes {
IScheduledCrossOrderedTasks(address(this)).triggerPendingScheduledCrossOrderedTasks();
LibERC20Votes.takeAbafCheckpoint(LibABAF.getAbaf());

uint256 delegatorBalance = LibTotalBalance.getTotalBalanceForAdjustedAt(
uint256 delegatorBalance = HoldOps.getTotalBalanceForAdjustedAt(
msg.sender,
LibTimeTravel.getBlockTimestamp()
);
Expand Down
Loading
Loading