ERC20PaymentClientBase_v1.sol
ERC20PaymentClientBase_v1
Inherits: IERC20PaymentClientBase_v1, Module_v1
Author: Inverter Network
Enables modules within the Inverter Network to create and manage payment orders that can be processed by authorized payment processors, ensuring efficient and secure transactions.
Utilizes {SafeERC20} for token operations and integrates with {IPaymentProcessor_v1} to handle token payments. This abstract contract must be extended by modules that manage {ERC20} payment orders, supporting complex payment scenarios.
State Variables
_orders
The list of oustanding orders.
Emptied whenever orders are collected.
PaymentOrder[] internal _orders;_outstandingTokenAmounts
The current cumulative amount of tokens outstanding.
mapping(address => uint) internal _outstandingTokenAmounts;_flagCount
The number of payment processor flags used by this payment client.
_flags
The payment processor flags used by this payment client.
__gap
Storage gap for future upgrades.
Functions
supportsInterface
See {IERC165-supportsInterface}.
validRecipient
Modifier to guarantee the recipient is valid.
validAmount
Modifier to guarantee the amount is valid.
validPaymentOrder
Modifier to guarantee the payment order is valid.
__ERC20PaymentClientBase_v1_init
Initializes the staking contract.
Parameters
flags_
uint8[]
The flags, represented as an array of uint8 containing the flag IDs between 0 and 255.
_addPaymentOrder
Adds a new {PaymentOrder} to the list of outstanding orders.
Parameters
order
PaymentOrder
The new payment order.
_addPaymentOrders
Adds a set of new {PaymentOrder}s to the list of outstanding orders.
Parameters
orders
PaymentOrder[]
The list of new Payment Orders.
_setFlags
Sets the flags for the PaymentOrders.
Parameters
flagCount_
uint8
The number of flags.
flags_
uint8[]
The flags, represented as an array of uint8 containing the flag IDs between 0 and 255.
paymentOrders
Returns the list of outstanding payment orders.
Returns
<none>
PaymentOrder[]
list of payment orders.
outstandingTokenAmount
Returns the total outstanding token payment amount.
Parameters
token_
address
The token in which to pay.
Returns
total_
uint256
amount of token to pay.
collectPaymentOrders
Collects outstanding payment orders.
Marks the orders as completed for the client.
Returns
paymentOrders_
PaymentOrder[]
list of payment orders.
tokens_
address[]
list of token addresses.
totalAmounts_
uint256[]
list of amounts.
amountPaid
Notifies the PaymentClient, that tokens have been paid out accordingly.
Payment Client will reduce the total amount of tokens it will stock up by the given amount.
Parameters
token_
address
The token in which the payment was made.
amount_
uint256
amount of tokens that have been paid out.
getFlags
Returns the flags used when creating payment orders in this client.
Returns
flags_
bytes32
The flags this client will use.
getFlagCount
Returns the number of flags this client uses for PaymentOrders.
Returns
flagCount_
uint8
The number of flags.
_ensureValidRecipient
Ensures the recipient is valid.
Parameters
recipient
address
The recipient to check.
_ensureValidAmount
Ensures the amount is valid.
Parameters
amount
uint256
The amount to check.
_ensureValidToken
Ensures the token is valid.
Parameters
token
address
The token to check.
_ensureValidPaymentOrder
Ensures the payment order is valid.
Parameters
order
PaymentOrder
The payment order to check.
_ensureTokenBalance
Ensures amount of payment tokens exist in address(this). In case the token being paid out is the FundingManager token, it will trigger a callback to the FundingManager to transfer the tokens to
_ensureTokenAllowance
Ensures amount of token allowance for payment processor(s).
_isAuthorizedPaymentProcessor
Returns whether address who is an authorized payment processor.
_assemblePaymentConfig
Returns the payment configuration from a list of supplied flag values. Can be overriden to add additional validation steps.
Last updated