-
Notifications
You must be signed in to change notification settings - Fork 16
Streaming Payment Processor
File: StreamingPaymentProcessor.sol
- This is another type of payment processor, that is used to process pre-existing payment orders.
- It enables Linear Vesting Curve.
- The payment module handles the money flow to the paymentReceivers (e.g. how many tokens are sent to which paymentReceiver at what time).
- Concurrent streaming allows for several active vestings per destination address.
- onlyModule
modifier onlyModule()
Checks whether the caller is an active module or not.
- validClient
modifier validClient(IERC20PaymentClient client)
Checks whether the client is calling for itself. The PaymentManager cannot call on other client's orders.
- activePaymentReceiver
modifier activePaymentReceiver(address client, address paymentReceiver)
Checks whether the paymentReceiver
actually has something remaining to be claimed or not.
function isActivePaymentReceiver(address client, address paymentReceiver)
external
view
returns (bool);
Tells whether a paymentReceiver has any pending payments for a particular client. This function is for convenience and can be easily figured out by other means in the codebase.
- address client: Address of the payment client
- address paymentReceiver: Address of the paymentReceiver
- bool: Whether paymentReceiver has pending payments or not.
function startForSpecificWalletId(
address client,
address paymentReceiver,
uint walletId
) external view returns (uint);
Getter for the start timestamp of a particular payment order with id = walletId associated with a particular paymentReceiver.
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- uint walletId: Id of the wallet for which start is fetched
- uint: the start timestamp of a particular payment order
function dueToForSpecificWalletId(
address client,
address paymentReceiver,
uint walletId
) external view returns (uint);
Getter for the vesting dueTo timestamp of a particular payment order with id = walletId associated with a particular paymentReceiver
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- uint walletId: Id of the wallet for which start is fetched
- uint: the vesting dueTo timestamp of a particular payment order
function releasedForSpecificWalletId(
address client,
address paymentReceiver,
uint walletId
) external view returns (uint);
Getter for the number of tokens already released for a particular payment order with id = walletId associated with a particular paymentReceiver
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- uint walletId: Id of the wallet for which start is fetched
- uint: number of tokens already released for a particular payment order
function vestedAmountForSpecificWalletId(
address client,
address paymentReceiver,
uint timestamp,
uint walletId
) external view returns (uint);
Calculates the number of tokens that have already vested for a particular payment order with id = walletId associated with a particular paymentReceiver.
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- uint timestamp: the time upto which we want the vested amount
- uint walletId: Id of the wallet for which start is fetched
- uint: number of tokens that have already vested
function releasableForSpecificWalletId(
address client,
address paymentReceiver,
uint walletId
) external view returns (uint);
Getter for the number of releasable tokens for a particular payment order with id = walletId associated with a particular paymentReceiver.
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- uint walletId: Id of the wallet for which start is fetched
- uint: number of releasable tokens for a particular payment order
function unclaimable(address client, address paymentReceiver)
external
view
returns (uint);
Getter for the number of tokens that could not be claimed.
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- uint: number of tokens that could not be claimed.
function viewAllPaymentOrders(address client, address paymentReceiver)
external
view
returns (VestingWallet[] memory);
See all active payment orders for a paymentClient associated with a particular paymentReceiver. The paymentReceiver must be an active paymentReceiver for the particular payment client
- address client: address of the payment client
- address paymentReceiver: PaymentReceiver's address.
- VestingWallet[]: A VestingWallet struct is used to store the payment order for a particular paymentReceiver by a particular payment client. This is an array of all eligible vesting wallets.
function init(
IOrchestrator orchestrator_,
Metadata memory metadata,
bytes memory
) external override(Module) initializer
Used to initialize the module. Has to be necessarily implemented in all modules.
- IOrchestrator orchestrator_: Instance of the orchestrator for which this module is being used
- Metadata metadata: Metadata about the StreamingPaymentProcessor module
function claimAll(IERC20PaymentClient client) external;
Claim everything that the paymentClient owes to the _msgSender till the current timestamp. This function should be callable if the _msgSender is either an activePaymentReceiver or has some unclaimedAmounts
- IERC20PaymentClient client: The {IERC20PaymentClient} instance to process all claims from _msgSender
function claimForSpecificWalletId(
IERC20PaymentClient client,
uint walletId,
bool retryForUnclaimableAmounts
) external;
Claim the salary uptil block.timestamp from the client for a payment order with id = walletId by _msgSender. If for a specific walletId, the tokens could not be transferred for some reason, it will added to the unclaimableAmounts of the paymentReceiver, and the amount would no longer hold any co-relation with the specific walletId of the paymentReceiver.
- IERC20PaymentClient client: The {IERC20PaymentClient} instance to process the walletId claim from _msgSender
- uint walletId: The ID of the payment order for which claim is being made
- bool retryForUnclaimableAmounts: boolean which determines if the function will try to pay the unclaimable amounts from earlier along with the vested salary from the payment order with id = walletId
function processPayments(IERC20PaymentClient client) external;
Processes all payments from an {IERC20PaymentClient} instance.
- IERC20PaymentClient client: The {IERC20PaymentClient} instance to process its to payments
function cancelRunningPayments(IERC20PaymentClient client) external;
- IERC20PaymentClient client: The {IERC20PaymentClient} instance to process its to payments
Cancels all unfinished payments from an {IERC20PaymentClient} instance.
function removeAllPaymentReceiverPayments(
IERC20PaymentClient client,
address paymentReceiver
) external;
Deletes all payments related to a paymentReceiver & leaves unvested tokens in the ERC20PaymentClient. This function calls _removePayment
which goes through all the payment orders for a paymentReceiver
. For the payment orders that are completely vested, their details are deleted in the _claimForSpecificWalletId
function, and for others it is deleted in the _removePayment function only, leaving the unvested tokens as the balance of the paymentClient itself.
- IERC20PaymentClient client: The {IERC20PaymentClient} instance from which we will remove the payments
- address paymentReceiver: PaymentReceiver's address.
function removePaymentForSpecificWalletId(
IERC20PaymentClient client,
address paymentReceiver,
uint walletId,
bool retryForUnclaimableAmounts
) external;
Deletes a specific payment with id = walletId for a paymentReceiver & leaves unvested tokens in the ERC20PaymentClient. The detail of the wallet that is being removed is either deleted in the _claimForSpecificWalletId or later down in this function itself depending on the timestamp of when this function was called.
- IERC20PaymentClient client: The {IERC20PaymentClient} instance from which we will remove the payment
- address paymentReceiver: address of the paymentReceiver whose payment order is to be removed
- uint walletId: The ID of the paymentReceiver's payment order which is to be removed
- bool retryForUnclaimableAmounts: boolean that determines whether the function would try to return the unclaimableAmounts along with the vested amounts from the payment order with id = walletId to the paymentReceiver