Skip to content

Commit

Permalink
feat(FM_PC_ExternalPrice_Redeeming): add new paymennt order struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Zitzak committed Jan 15, 2025
1 parent 4dbee90 commit dd17de3
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ contract FM_PC_ExternalPrice_Redeeming_v1 is

// Set direct operations only flag.
_setIsDirectOperationsOnly(isDirectOperationsOnly_);

// Set the flags for the PaymentOrders
// The Module will use 1 flag
uint8[] memory flags = new uint8[](1);
// The module only uses the OrderId, which is flag_ID 0 (see IERC20PaymentClientBase_v1)
flags[0] = 0;

__ERC20PaymentClientBase_v1_init(flags);
}

// -------------------------------------------------------------------------
Expand Down Expand Up @@ -462,22 +470,32 @@ contract FM_PC_ExternalPrice_Redeeming_v1 is
uint issuanceFeeAmount_
) internal {
// Generate new order ID.
_orderId = _nextOrderId++;
_orderId = ++_nextOrderId;

// Update open redemption amount.
_addToOpenRedemptionAmount(collateralRedeemAmount_);

// Calculate redemption amount.
uint redemptionAmount_ = collateralRedeemAmount_ - issuanceFeeAmount_;

bytes32 flags;
bytes32[] memory data;

{
bytes32[] memory paymentParameters = new bytes32[](1);
paymentParameters[0] = bytes32(_orderId);

(flags, data) = _assemblePaymentConfig(paymentParameters);
}
// Create and add payment order.
PaymentOrder memory order = PaymentOrder({
recipient: _msgSender(),
recipient: receiver_,
paymentToken: address(token()),
amount: collateralRedeemAmount_,
start: block.timestamp,
cliff: 0,
end: block.timestamp
originChainId: block.chainid,
targetChainId: block.chainid,
flags: flags,
data: data
});
_addPaymentOrder(order);

Expand Down

0 comments on commit dd17de3

Please sign in to comment.