Skip to content

Commit 501a279

Browse files
committed
Merge remote-tracking branch 'upstream/feature/FM_PC_Oracle_Redeeming_v1' into dev
2 parents bf4c916 + 587247c commit 501a279

37 files changed

+1449
-646
lines changed

src/external/token/ERC20Issuance_Blacklist_v1.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ contract ERC20Issuance_Blacklist_v1 is
105105
}
106106

107107
/// @inheritdoc IERC20Issuance_Blacklist_v1
108-
function isBlacklistManager(address account_) external view returns (bool) {
108+
function isBlacklistManager(address account_)
109+
external
110+
view
111+
returns (bool)
112+
{
109113
return _isBlacklistManager[account_];
110114
}
111115

@@ -135,9 +139,7 @@ contract ERC20Issuance_Blacklist_v1 is
135139
}
136140

137141
/// @inheritdoc IERC20Issuance_Blacklist_v1
138-
function addToBlacklistBatched(address[] memory accounts_)
139-
external
140-
{
142+
function addToBlacklistBatched(address[] memory accounts_) external {
141143
uint totalAccounts = accounts_.length;
142144
if (totalAccounts > BATCH_LIMIT) {
143145
revert ERC20Issuance_Blacklist_BatchLimitExceeded(
@@ -150,9 +152,7 @@ contract ERC20Issuance_Blacklist_v1 is
150152
}
151153

152154
/// @inheritdoc IERC20Issuance_Blacklist_v1
153-
function removeFromBlacklistBatched(address[] memory accounts_)
154-
external
155-
{
155+
function removeFromBlacklistBatched(address[] memory accounts_) external {
156156
uint totalAccounts = accounts_.length;
157157
if (totalAccounts > BATCH_LIMIT) {
158158
revert ERC20Issuance_Blacklist_BatchLimitExceeded(

src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

+22-4
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ contract FM_PC_ExternalPrice_Redeeming_v1 is
218218

219219
// Set direct operations only flag.
220220
_setIsDirectOperationsOnly(isDirectOperationsOnly_);
221+
222+
// Set the flags for the PaymentOrders
223+
// The Module will use 1 flag
224+
uint8[] memory flags = new uint8[](1);
225+
// The module only uses the OrderId, which is flag_ID 0 (see IERC20PaymentClientBase_v1)
226+
flags[0] = 0;
227+
228+
__ERC20PaymentClientBase_v1_init(flags);
221229
}
222230

223231
// -------------------------------------------------------------------------
@@ -453,22 +461,32 @@ contract FM_PC_ExternalPrice_Redeeming_v1 is
453461
uint issuanceFeeAmount_
454462
) internal {
455463
// Generate new order ID.
456-
_orderId = _orderId++;
464+
_orderId = ++_orderId;
457465

458466
// Update open redemption amount.
459467
_addToOpenRedemptionAmount(collateralRedeemAmount_);
460468

461469
// collateralRedeemAmount_ is already calculated from netDeposit (post-issuance fee)
462470
uint redemptionAmount_ = collateralRedeemAmount_;
463471

472+
bytes32 flags;
473+
bytes32[] memory data;
474+
475+
{
476+
bytes32[] memory paymentParameters = new bytes32[](1);
477+
paymentParameters[0] = bytes32(_orderId);
478+
479+
(flags, data) = _assemblePaymentConfig(paymentParameters);
480+
}
464481
// Create and add payment order.
465482
PaymentOrder memory order = PaymentOrder({
466483
recipient: receiver_,
467484
paymentToken: address(token()),
468485
amount: collateralRedeemAmount_,
469-
start: block.timestamp,
470-
cliff: 0,
471-
end: block.timestamp
486+
originChainId: block.chainid,
487+
targetChainId: block.chainid,
488+
flags: flags,
489+
data: data
472490
});
473491
_addPaymentOrder(order);
474492

src/modules/logicModule/LM_PC_Bounties_v1.sol

+9-3
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ contract LM_PC_Bounties_v1 is ILM_PC_Bounties_v1, ERC20PaymentClientBase_v1 {
275275
bytes memory
276276
) external override(Module_v1) initializer {
277277
__Module_init(orchestrator_, metadata);
278+
// This module does not use any PaymentOrder flags.
279+
__ERC20PaymentClientBase_v1_init(new uint8[](0));
278280
// init empty list of bounties and claims
279281
_bountyList.init();
280282
_claimList.init();
@@ -519,14 +521,18 @@ contract LM_PC_Bounties_v1 is ILM_PC_Bounties_v1, ERC20PaymentClientBase_v1 {
519521
for (uint i; i < length;) {
520522
contrib = contribs[i];
521523

524+
(bytes32 flags, bytes32[] memory data) =
525+
_assemblePaymentConfig(new bytes32[](0)); // No additional payment data
526+
522527
_addPaymentOrder(
523528
PaymentOrder({
524529
recipient: contrib.addr,
525530
paymentToken: address(orchestrator().fundingManager().token()),
526531
amount: contrib.claimAmount,
527-
start: block.timestamp,
528-
cliff: 0,
529-
end: block.timestamp // end date is now
532+
originChainId: block.chainid,
533+
targetChainId: block.chainid,
534+
flags: flags,
535+
data: data
530536
})
531537
);
532538
unchecked {

src/modules/logicModule/LM_PC_KPIRewarder_v1.sol

+16-7
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ contract LM_PC_KPIRewarder_v1 is
7979

8080
// KPI and Configuration Storage
8181
/// @dev The number of KPIs created.
82-
uint public KPICounter;
82+
uint internal KPICounter;
8383
/// @dev Registry of KPIsid -> KPI.
84-
mapping(uint => KPI) public registryOfKPIs;
84+
mapping(uint => KPI) internal registryOfKPIs;
8585
/// @dev Registry of Assertion Configurations assertionId -> RewardRoundConfiguration.
86-
mapping(bytes32 => RewardRoundConfiguration) public assertionConfig;
87-
86+
mapping(bytes32 => RewardRoundConfiguration) internal assertionConfig;
8887
/// @dev For locking certain utilities when there are assertions open.
89-
bool public assertionPending;
88+
bool internal assertionPending;
9089

9190
/// @dev Storage gap for future upgrades.
9291
uint[50] private __gap;
@@ -136,19 +135,29 @@ contract LM_PC_KPIRewarder_v1 is
136135
// View functions
137136

138137
/// @inheritdoc ILM_PC_KPIRewarder_v1
139-
function getKPI(uint KPInum) public view returns (KPI memory) {
138+
function getKPI(uint KPInum) external view returns (KPI memory) {
140139
return registryOfKPIs[KPInum];
141140
}
142141

143142
/// @inheritdoc ILM_PC_KPIRewarder_v1
144143
function getAssertionConfig(bytes32 assertionId)
145-
public
144+
external
146145
view
147146
returns (RewardRoundConfiguration memory)
148147
{
149148
return assertionConfig[assertionId];
150149
}
151150

151+
/// @inheritdoc ILM_PC_KPIRewarder_v1
152+
function getKPICounter() external view returns (uint) {
153+
return KPICounter;
154+
}
155+
156+
/// @inheritdoc ILM_PC_KPIRewarder_v1
157+
function getAssertionPending() external view returns (bool) {
158+
return assertionPending;
159+
}
160+
152161
// ========================================================================
153162
// Assertion Manager functions:
154163

src/modules/logicModule/LM_PC_PaymentRouter_v1.sol

+63-19
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ contract LM_PC_PaymentRouter_v1 is
6060
/// @dev The role that allows the pushing of payments.
6161
bytes32 public constant PAYMENT_PUSHER_ROLE = "PAYMENT_PUSHER";
6262

63+
//--------------------------------------------------------------------------
64+
// Initializer
65+
function init(
66+
IOrchestrator_v1 orchestrator_,
67+
Metadata memory metadata,
68+
bytes memory configData
69+
) external override(Module_v1) initializer {
70+
__Module_init(orchestrator_, metadata);
71+
72+
// Set the flags for the PaymentOrders
73+
uint8[] memory flags = new uint8[](3); // The Module will use 3 flags
74+
flags[0] = 1; // start, flag_ID 1
75+
flags[1] = 2; // cliff, flag_ID 2
76+
flags[2] = 3; // end, flag_ID 3
77+
78+
__ERC20PaymentClientBase_v1_init(flags);
79+
}
80+
6381
//--------------------------------------------------------------------------
6482
// Mutating Functions
6583

@@ -72,16 +90,29 @@ contract LM_PC_PaymentRouter_v1 is
7290
uint cliff,
7391
uint end
7492
) public onlyModuleRole(PAYMENT_PUSHER_ROLE) {
75-
_addPaymentOrder(
76-
PaymentOrder(
77-
recipient,
78-
paymentToken,
79-
amount,
80-
start == 0 ? block.timestamp : start,
81-
cliff,
82-
end
83-
)
84-
);
93+
bytes32 flags;
94+
bytes32[] memory data;
95+
96+
{
97+
bytes32[] memory paymentParameters = new bytes32[](3);
98+
paymentParameters[0] = bytes32(start);
99+
paymentParameters[1] = bytes32(cliff);
100+
paymentParameters[2] = bytes32(end);
101+
102+
(flags, data) = _assemblePaymentConfig(paymentParameters);
103+
}
104+
105+
PaymentOrder memory order = PaymentOrder({
106+
recipient: recipient,
107+
paymentToken: paymentToken,
108+
amount: amount,
109+
originChainId: block.chainid,
110+
targetChainId: block.chainid,
111+
flags: flags,
112+
data: data
113+
});
114+
115+
_addPaymentOrder(order);
85116

86117
// call PaymentProcessor
87118
__Module_orchestrator.paymentProcessor().processPayments(
@@ -105,20 +136,33 @@ contract LM_PC_PaymentRouter_v1 is
105136
|| paymentTokens.length != numOfOrders
106137
|| amounts.length != numOfOrders
107138
) {
108-
revert Module__ERC20PaymentClientBase__ArrayLengthMismatch();
139+
revert Module__LM_PC_PaymentRouter_v1__ArrayLengthMismatch();
140+
}
141+
142+
bytes32 flags;
143+
bytes32[] memory data;
144+
145+
{
146+
bytes32[] memory paymentParameters = new bytes32[](3);
147+
paymentParameters[0] = bytes32(start);
148+
paymentParameters[1] = bytes32(cliff);
149+
paymentParameters[2] = bytes32(end);
150+
151+
(flags, data) = _assemblePaymentConfig(paymentParameters);
109152
}
110153

111154
// Loop through the arrays and add Payments
112155
for (uint8 i = 0; i < numOfOrders; i++) {
113156
_addPaymentOrder(
114-
PaymentOrder(
115-
recipients[i],
116-
paymentTokens[i],
117-
amounts[i],
118-
start == 0 ? block.timestamp : start,
119-
cliff,
120-
end
121-
)
157+
PaymentOrder({
158+
recipient: recipients[i],
159+
paymentToken: paymentTokens[i],
160+
amount: amounts[i],
161+
originChainId: block.chainid,
162+
targetChainId: block.chainid,
163+
flags: flags,
164+
data: data
165+
})
122166
);
123167
}
124168

src/modules/logicModule/LM_PC_RecurringPayments_v1.sol

+32-10
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ contract LM_PC_RecurringPayments_v1 is
128128
// Set empty list of RecurringPayment
129129
_paymentList.init();
130130

131+
// Set the epoch Data
131132
uint newEpochLength = abi.decode(configData, (uint));
132133
epochLength = newEpochLength;
133134

@@ -137,6 +138,13 @@ contract LM_PC_RecurringPayments_v1 is
137138
}
138139

139140
emit EpochLengthSet(newEpochLength);
141+
142+
// Set the flags for the PaymentOrders
143+
uint8[] memory flags = new uint8[](2); // The Module will use 2 flags
144+
flags[0] = 1; // start, flag_ID 1
145+
flags[1] = 3; // end, flag_ID 3
146+
147+
__ERC20PaymentClientBase_v1_init(flags);
140148
}
141149

142150
//--------------------------------------------------------------------------
@@ -297,6 +305,21 @@ contract LM_PC_RecurringPayments_v1 is
297305
currentEpoch - currentPayment.lastTriggeredEpoch;
298306
// If order hasnt been triggered this epoch
299307
if (epochsNotTriggered > 0) {
308+
// assemble data array
309+
310+
bytes32 flags;
311+
bytes32[] memory data;
312+
313+
{
314+
bytes32[] memory paymentParameters = new bytes32[](2);
315+
paymentParameters[0] = bytes32(block.timestamp);
316+
paymentParameters[1] =
317+
bytes32((currentEpoch + 1) * epochLength);
318+
319+
(flags, data) =
320+
_assemblePaymentConfig(paymentParameters);
321+
}
322+
300323
// add paymentOrder for this epoch
301324
_addPaymentOrder(
302325
PaymentOrder({
@@ -305,29 +328,28 @@ contract LM_PC_RecurringPayments_v1 is
305328
orchestrator().fundingManager().token()
306329
),
307330
amount: currentPayment.amount,
308-
start: block.timestamp,
309-
cliff: 0,
310-
// End of current epoch is the end date
311-
end: (currentEpoch + 1) * epochLength
331+
originChainId: block.chainid,
332+
targetChainId: block.chainid,
333+
flags: flags,
334+
data: data
312335
})
313336
);
314337

315338
// if past epochs have not been triggered
316339
if (epochsNotTriggered > 1) {
340+
data[1] = bytes32(currentEpoch * epochLength);
317341
_addPaymentOrder(
318342
PaymentOrder({
319343
recipient: currentPayment.recipient,
320-
// because we already made a payment that for the current epoch
321344
paymentToken: address(
322345
orchestrator().fundingManager().token()
323346
),
324347
amount: currentPayment.amount
325348
* (epochsNotTriggered - 1),
326-
start: block.timestamp,
327-
cliff: 0,
328-
// Payment was already due so end is start of this epoch which should
329-
// already have passed
330-
end: currentEpoch * epochLength
349+
originChainId: block.chainid,
350+
targetChainId: block.chainid,
351+
flags: flags,
352+
data: data
331353
})
332354
);
333355
}

0 commit comments

Comments
 (0)