IPP_Streaming_v1.sol

Git Source

Inherits: IPaymentProcessor_v1

Functions

claimAll

claim everything that the paymentClient owes to the _msgSender till the current timestamp.

This function should be callable if the _msgSender is an activePaymentReceiver.

function claimAll(address client) external;

Parameters

Name
Type
Description

client

address

The {IERC20PaymentClientBase_v1} instance address that processes all claims from _msgSender.

claimForSpecificStream

claim the total amount up til block.timestamp from the client for a payment order with id = streamId by _msgSender.

If for a specific streamId, 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 he specific streamId of the paymentReceiver.

function claimForSpecificStream(address client, uint streamId) external;

Parameters

Name
Type
Description

client

address

The {IERC20PaymentClientBase_v1} instance address that processes the streamId claim from _msgSender.

streamId

uint256

The ID of the streaming payment order for which claim is being made.

removeAllPaymentReceiverPayments

Deletes all payments related to a paymentReceiver & leaves currently streaming tokens in the {IERC20PaymentClientBase_v1}.

this function calls _removePayment which goes through all the payment orders for a paymentReceiver. For the payment orders that are completely streamed, their details are deleted in the _claimForSpecificStrea function and for others it is deleted in the _removePayment function only, leaving the currently streaming tokens as balance of the paymentClient itself.

function removeAllPaymentReceiverPayments(
    address client,
    address paymentReceiver
) external;

Parameters

Name
Type
Description

client

address

The {IERC20PaymentClientBase_v1} instance address from which we will remove the payments.

paymentReceiver

address

PaymentReceiver's address.

removePaymentForSpecificStream

Deletes a specific payment with id = streamId for a paymentReceiver & leaves currently streaming tokens in the {IERC20PaymentClientBase_v1}.

the detail of the wallet that is being removed is either deleted in the _claimForSpecificStream or later down in this function itself depending on the timestamp of when this function was called.

function removePaymentForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId
) external;

Parameters

Name
Type
Description

client

address

The {IERC20PaymentClientBase_v1} instance address from which we will remove the payment.

paymentReceiver

address

Address of the paymentReceiver whose payment order is to be removed.

streamId

uint256

The ID of the paymentReceiver's payment order which is to be removed.

startForSpecificStream

Getter for the start timestamp of a particular payment order with id = streamId associated with a particular paymentReceiver.

function startForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId
) external view returns (uint);

Parameters

Name
Type
Description

client

address

address of the payment client.

paymentReceiver

address

PaymentReceiver's address.

streamId

uint256

Id of the wallet for which start is fetched.

Returns

Name
Type
Description

<none>

uint256

start timestamp of the payment order.

cliffForSpecificStream

Getter for the cliff duration of a particular payment order with id = streamId associated with a particular paymentReceiver.

function cliffForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId
) external view returns (uint);

Parameters

Name
Type
Description

client

address

address of the payment client.

paymentReceiver

address

PaymentReceiver's address.

streamId

uint256

Id of the wallet for which cliff is fetched.

Returns

Name
Type
Description

<none>

uint256

cliff duration of the payment order.

endForSpecificStream

Getter for the stream end timestamp of a particular payment order with id = streamId associated with a particular paymentReceiver.

function endForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId
) external view returns (uint);

Parameters

Name
Type
Description

client

address

address of the payment client.

paymentReceiver

address

PaymentReceiver's address.

streamId

uint256

Id of the wallet for which end is fetched.

Returns

Name
Type
Description

<none>

uint256

end timestamp of the payment order.

releasedForSpecificStream

Getter for the amount of tokens already released for a particular payment order with id = streamId associated with a particular paymentReceiver.

function releasedForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId
) external view returns (uint);

Parameters

Name
Type
Description

client

address

address of the payment client.

paymentReceiver

address

PaymentReceiver's address.

streamId

uint256

Id of the wallet for which released is fetched.

Returns

Name
Type
Description

<none>

uint256

released amount of the payment order.

streamedAmountForSpecificStream

Calculates the amount of tokens that has already streamed for a particular payment order with id = streamId associated with a particular paymentReceiver.

function streamedAmountForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId,
    uint timestamp
) external view returns (uint);

Parameters

Name
Type
Description

client

address

paymentReceiver

address

PaymentReceiver's address.

streamId

uint256

Id of the wallet for which the streamed amount is fetched.

timestamp

uint256

the time upto which we want the streamed amount.

Returns

Name
Type
Description

<none>

uint256

streamed amount of the stream with id = streamId.

releasableForSpecificStream

Getter for the amount of releasable tokens for a particular payment order with id = streamId associated with a particular paymentReceiver.

function releasableForSpecificStream(
    address client,
    address paymentReceiver,
    uint streamId
) external view returns (uint);

Parameters

Name
Type
Description

client

address

paymentReceiver

address

PaymentReceiver's address.

streamId

uint256

Id of the wallet for which the releasable amount is fetched.

Returns

Name
Type
Description

<none>

uint256

releasable amount of the stream with id = streamId.

viewAllPaymentOrders

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.

function viewAllPaymentOrders(address client, address paymentReceiver)
    external
    view
    returns (Stream[] memory);

Parameters

Name
Type
Description

client

address

Address of the payment client.

paymentReceiver

address

Address of the paymentReceiver.

Returns

Name
Type
Description

<none>

Stream[]

all streams for a particular payment client and payment receiver.

isActivePaymentReceiver

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.

function isActivePaymentReceiver(address client, address paymentReceiver)
    external
    view
    returns (bool);

Parameters

Name
Type
Description

client

address

Address of the payment client.

paymentReceiver

address

Address of the paymentReceiver.

Returns

Name
Type
Description

<none>

bool

true if the paymentReceiver is active for the payment client.

Events

StreamingPaymentAdded

Emitted when a payment gets processed for execution.

event StreamingPaymentAdded(
    address indexed paymentClient,
    address indexed recipient,
    address indexed paymentToken,
    uint streamId,
    uint amount,
    uint start,
    uint cliff,
    uint end
);

Parameters

Name
Type
Description

paymentClient

address

The payment client that originated the order.

recipient

address

The address that will receive the payment.

paymentToken

address

The address of the token that is being used for the payment.

streamId

uint256

ID of the streaming payment order that was added.

amount

uint256

The amount of tokens the payment consists of.

start

uint256

The start date of the streaming period.

cliff

uint256

The duration of the cliff period.

end

uint256

The ending of the streaming period.

StreamingPaymentRemoved

Emitted when the stream to an address is removed.

event StreamingPaymentRemoved(
    address indexed paymentClient, address indexed recipient, uint streamId
);

Parameters

Name
Type
Description

paymentClient

address

The payment client that originated the order.

recipient

address

The address that will stop receiving payment.

streamId

uint256

ID of the streaming payment order that was removed.

InvalidStreamingOrderDiscarded

Emitted when a running stream schedule gets updated.

event InvalidStreamingOrderDiscarded(
    address indexed recipient,
    address indexed paymentToken,
    uint amount,
    uint start,
    uint cliff,
    uint end
);

Parameters

Name
Type
Description

recipient

address

The address that will receive the payment.

paymentToken

address

The address of the token that will be used for the payment.

amount

uint256

The amount of tokens the payment consists of.

start

uint256

The start date of the streaming period.

cliff

uint256

The duration of the cliff period.

end

uint256

The ending of the streaming period.

UnclaimableAmountAdded

Emitted when a payment was unclaimable due to a token error.

event UnclaimableAmountAdded(
    address indexed paymentClient,
    address recipient,
    address paymentToken,
    uint streamId,
    uint amount
);

Parameters

Name
Type
Description

paymentClient

address

The payment client that originated the order.

recipient

address

The address that wshould have received the payment.

paymentToken

address

The address of the token that will be used for the payment.

streamId

uint256

ID of the streaming payment order that was processed.

amount

uint256

The amount of tokens that were unclaimable.

PaymentReceiverRemoved

Emitted when an address is removed from the list of active payment receiver, eg because all payments have been fulfilled by a client.

event PaymentReceiverRemoved(
    address indexed paymentClient, address indexed paymentReceiver
);

Parameters

Name
Type
Description

paymentClient

address

The address of the payment client.

paymentReceiver

address

The address of the recipient that is removed.

Errors

Module__PP_Streaming__InsufficientTokenBalanceInClient

insufficient tokens in the client to do payments.

error Module__PP_Streaming__InsufficientTokenBalanceInClient();

Module__PP_Streaming__InvalidStream

paymentReceiver's streamId for the paymentClient is not valid.

error Module__PP_Streaming__InvalidStream(
    address paymentClient, address paymentReceiver, uint streamId
);

Parameters

Name
Type
Description

paymentClient

address

The payment client that originated the order.

paymentReceiver

address

The address that will receive the payment.

streamId

uint256

ID of the streaming payment order that was processed.

Module__PP_Streaming__InactiveStream

paymentReceiver's streamId for the paymentClient is no longer active.

error Module__PP_Streaming__InactiveStream(
    address paymentClient, address paymentReceiver, uint streamId
);

Parameters

Name
Type
Description

paymentClient

address

The payment client that originated the order.

paymentReceiver

address

The address that will receive the payment.

streamId

uint256

ID of the streaming payment order that was processed.

Module__PP_Streaming__In_validPaymentReceiver

the paymentReceiver for the given paymentClient does not exist (anymore).

error Module__PP_Streaming__In_validPaymentReceiver(
    address paymentClient, address paymentReceiver
);

Parameters

Name
Type
Description

paymentClient

address

The payment client that originated the order.

paymentReceiver

address

The address that will receive the payment.

Module__PP_Streaming__InvalidDefaultTimes

The default start, cliff and end times are invalid.

error Module__PP_Streaming__InvalidDefaultTimes(
    uint start, uint cliff, uint end
);

Parameters

Name
Type
Description

start

uint256

The start time.

cliff

uint256

The cliff duration.

end

uint256

The end time.

Structs

Stream

This struct is used to store the payment order for a particular paymentReceiver by a particular payment client.

for _streamId, valid values will start from 1. 0 is not a valid id.

struct Stream {
    address _paymentToken;
    uint _streamId;
    uint _total;
    uint _released;
    uint _start;
    uint _cliff;
    uint _end;
}

Properties

Name
Type
Description

_paymentToken

address

The address of the token that is being used for the payment.

_streamId

uint256

A unique identifier of a stream for a specific paymentClient and paymentReceiver combination.

_total

uint256

The total amount that the paymentReceiver should eventually get.

_released

uint256

The amount that has been claimed by the paymentReceiver till now.

_start

uint256

The start date of the streaming period.

_cliff

uint256

The duration of the cliff period.

_end

uint256

The ending of the streaming period.

Last updated