Module ITIP20ChannelReserve
Expand description
TIP-20 channel reserve ABI.
The reserve locks payer deposits, verifies EIP-712 cumulative vouchers, pays the payee incrementally, and lets the payer withdraw the remaining balance after a close grace period.
interface ITIP20ChannelReserve {
struct ChannelDescriptor { address payer; address payee; address operator; address token; bytes32 salt; address authorizedSigner; bytes32 expiringNonceHash; }
struct ChannelState { uint96 settled; uint96 deposit; uint32 closeRequestedAt; }
struct Channel { ChannelDescriptor descriptor; ChannelState state; }
function CLOSE_GRACE_PERIOD() external view returns (uint64);
function VOUCHER_TYPEHASH() external view returns (bytes32);
function open(address payee, address operator, address token, uint96 deposit, bytes32 salt, address authorizedSigner) external returns (bytes32 channelId);
function settle(ChannelDescriptor calldata descriptor, uint96 cumulativeAmount, bytes calldata signature) external;
function topUp(ChannelDescriptor calldata descriptor, uint96 additionalDeposit) external;
function close(ChannelDescriptor calldata descriptor, uint96 cumulativeAmount, uint96 captureAmount, bytes calldata signature) external;
function requestClose(ChannelDescriptor calldata descriptor) external;
function withdraw(ChannelDescriptor calldata descriptor) external;
function getChannel(ChannelDescriptor calldata descriptor) external view returns (Channel memory);
function getChannelState(bytes32 channelId) external view returns (ChannelState memory);
function getChannelStatesBatch(bytes32[] calldata channelIds) external view returns (ChannelState[] memory);
function computeChannelId(address payer, address payee, address operator, address token, bytes32 salt, address authorizedSigner, bytes32 expiringNonceHash) external view returns (bytes32);
function getVoucherDigest(bytes32 channelId, uint96 cumulativeAmount) external view returns (bytes32);
function domainSeparator() external view returns (bytes32);
event ChannelOpened(bytes32 indexed channelId, address indexed payer, address indexed payee, address operator, address token, address authorizedSigner, bytes32 salt, bytes32 expiringNonceHash, uint96 deposit);
event Settled(bytes32 indexed channelId, address indexed payer, address indexed payee, uint96 cumulativeAmount, uint96 deltaPaid, uint96 newSettled);
event TopUp(bytes32 indexed channelId, address indexed payer, address indexed payee, uint96 additionalDeposit, uint96 newDeposit);
event CloseRequested(bytes32 indexed channelId, address indexed payer, address indexed payee, uint256 closeGraceEnd);
event ChannelClosed(bytes32 indexed channelId, address indexed payer, address indexed payee, uint96 settledToPayee, uint96 refundedToPayer);
event CloseRequestCancelled(bytes32 indexed channelId, address indexed payer, address indexed payee);
error ChannelAlreadyExists();
error ChannelNotFound();
error NotPayer();
error NotPayeeOrOperator();
error InvalidPayee();
error ZeroDeposit();
error ExpiringNonceHashNotSet();
error InvalidSignature();
error AmountExceedsDeposit();
error AmountNotIncreasing();
error CaptureAmountInvalid();
error CloseNotReady();
error DepositOverflow();
}Modules§
- abi
- Contains dynamic ABI definitions for this contract.
Structs§
- Amount
Exceeds Deposit - Voucher or capture amount exceeds the channel deposit.
Custom error with signature
AmountExceedsDeposit()and selector0xbd0d7138. - Amount
NotIncreasing - Settlement amount must be greater than the current settled amount.
Custom error with signature
AmountNotIncreasing()and selector0x32d2c1a3. - CLOSE_
GRACE_ PERIOD Call - Delay between payer
requestCloseandwithdraw. Function with signatureCLOSE_GRACE_PERIOD()and selector0x956c8327. - CLOSE_
GRACE_ PERIOD Return - Delay between payer
requestCloseandwithdraw. Container type for the return parameters of theCLOSE_GRACE_PERIOD()function. - Capture
Amount Invalid - Close capture is below settled amount or above voucher amount.
Custom error with signature
CaptureAmountInvalid()and selector0xc91833a1. - Channel
- Full descriptor plus current state.
- Channel
Already Exists - Channel id already exists in persistent state or earlier in this transaction.
Custom error with signature
ChannelAlreadyExists()and selector0x0ec0f149. - Channel
Closed - Emitted when a channel is deleted by payee close or payer withdraw.
Event with signature
ChannelClosed(bytes32,address,address,uint96,uint96)and selector0x5613aed96d5bf39f928408dbe1d4143490b9bb5957eac2dd8e69b5dc4b2206e6. - Channel
Descriptor - Immutable channel identity supplied to all descriptor-based methods.
- Channel
NotFound - Descriptor resolves to an empty channel slot.
Custom error with signature
ChannelNotFound()and selector0x1e07dd94. - Channel
Opened - Emitted after a channel is opened and funded.
Event with signature
ChannelOpened(bytes32,address,address,address,address,address,bytes32,bytes32,uint96)and selector0xdebaba36f0e9c7978f536fed432d9360b1f9646d7ca88531c34c3eae43f154a7. - Channel
State - Mutable channel state packed into one native storage slot.
- Close
NotReady - Payer withdraw was attempted before the close grace period elapsed.
Custom error with signature
CloseNotReady()and selector0x02b81e29. - Close
Request Cancelled - Emitted when top-up clears a pending close request.
Event with signature
CloseRequestCancelled(bytes32,address,address)and selector0x6bbcbc59913c43e567847487b95410b0b65cf253531b1c6505b21f8359c838fe. - Close
Requested - Emitted when the payer starts the close grace timer.
Event with signature
CloseRequested(bytes32,address,address,uint256)and selector0xf5a36fc00a96cbb9cf1f8f59299165e1d8ffffe94396d82904b4da524d16bbce. - Deposit
Overflow - Top-up would overflow the packed deposit.
Custom error with signature
DepositOverflow()and selector0x1132981b. - Expiring
Nonce Hash NotSet - Handler did not seed the transaction-scoped open context hash.
Custom error with signature
ExpiringNonceHashNotSet()and selector0x102f04a9. - ITIP20
Channel Reserve Instance - A
ITIP20ChannelReserveinstance. - Invalid
Payee - Payee is zero or a TIP-20-prefix address.
Custom error with signature
InvalidPayee()and selector0xb387a238. - Invalid
Signature - Voucher signature did not recover to the expected signer.
Custom error with signature
InvalidSignature()and selector0x8baa579f. - NotPayee
OrOperator - Caller must be the descriptor payee or nonzero operator.
Custom error with signature
NotPayeeOrOperator()and selector0x626a2a3d. - NotPayer
- Caller must be the descriptor payer.
Custom error with signature
NotPayer()and selector0x1435e357. - Settled
- Emitted after voucher settlement pays a delta to the payee.
Event with signature
Settled(bytes32,address,address,uint96,uint96,uint96)and selector0x11c4e4c79ad8802431b44c15047ed1ddb82fbfc1abd452c765f7ee3990df1399. - TopUp
- Emitted after channel deposit changes or a close request is cancelled by top-up.
Event with signature
TopUp(bytes32,address,address,uint96,uint96)and selector0x2a96f534665f3150977dd4c35d91373c74030288edbb3cf83c527dd25012364f. - VOUCHER_
TYPEHASH Call - EIP-712 type hash for
Voucher(bytes32 channelId,uint96 cumulativeAmount). Function with signatureVOUCHER_TYPEHASH()and selector0x94739e87. - VOUCHER_
TYPEHASH Return - EIP-712 type hash for
Voucher(bytes32 channelId,uint96 cumulativeAmount). Container type for the return parameters of theVOUCHER_TYPEHASH()function. - Zero
Deposit - Initial deposit cannot be zero.
Custom error with signature
ZeroDeposit()and selector0x56316e87. - close
Call - Closes the channel from the payee/operator side and refunds uncaptured deposit.
Function with signature
close((address,address,address,address,bytes32,address,bytes32),uint96,uint96,bytes)and selector0x73b57f74. - close
Return - Closes the channel from the payee/operator side and refunds uncaptured deposit.
Container type for the return parameters of the
close((address,address,address,address,bytes32,address,bytes32),uint96,uint96,bytes)function. - compute
Channel IdCall - Computes the canonical channel id for a descriptor.
Function with signature
computeChannelId(address,address,address,address,bytes32,address,bytes32)and selector0x185eeeac. - compute
Channel IdReturn - Computes the canonical channel id for a descriptor.
Container type for the return parameters of the
computeChannelId(address,address,address,address,bytes32,address,bytes32)function. - domain
Separator Call - Returns the EIP-712 domain separator for the current chain.
Function with signature
domainSeparator()and selector0xf698da25. - domain
Separator Return - Returns the EIP-712 domain separator for the current chain.
Container type for the return parameters of the
domainSeparator()function. - getChannel
Call - Returns the descriptor and state for a channel.
Function with signature
getChannel((address,address,address,address,bytes32,address,bytes32))and selector0xeef95313. - getChannel
Return - Returns the descriptor and state for a channel.
Container type for the return parameters of the
getChannel((address,address,address,address,bytes32,address,bytes32))function. - getChannel
State Call - Returns the state for
channelId, or the zero state when absent. Function with signaturegetChannelState(bytes32)and selector0xd18da8b1. - getChannel
State Return - Returns the state for
channelId, or the zero state when absent. Container type for the return parameters of thegetChannelState(bytes32)function. - getChannel
States Batch Call - Returns states for
channelIdsin order. Function with signaturegetChannelStatesBatch(bytes32[])and selector0xd1f4cda2. - getChannel
States Batch Return - Returns states for
channelIdsin order. Container type for the return parameters of thegetChannelStatesBatch(bytes32[])function. - getVoucher
Digest Call - Computes the EIP-712 digest signed by the payer or authorized signer.
Function with signature
getVoucherDigest(bytes32,uint96)and selector0xf3b349e8. - getVoucher
Digest Return - Computes the EIP-712 digest signed by the payer or authorized signer.
Container type for the return parameters of the
getVoucherDigest(bytes32,uint96)function. - open
Call - Opens a channel and pulls
depositTIP-20 units frommsg.sender. Function with signatureopen(address,address,address,uint96,bytes32,address)and selector0xedc53b00. - open
Return - Opens a channel and pulls
depositTIP-20 units frommsg.sender. Container type for the return parameters of theopen(address,address,address,uint96,bytes32,address)function. - request
Close Call - Starts the payer withdrawal timer.
Function with signature
requestClose((address,address,address,address,bytes32,address,bytes32))and selector0x675402e5. - request
Close Return - Starts the payer withdrawal timer.
Container type for the return parameters of the
requestClose((address,address,address,address,bytes32,address,bytes32))function. - settle
Call - Pays the unsettled delta up to
cumulativeAmountusing a valid voucher. Function with signaturesettle((address,address,address,address,bytes32,address,bytes32),uint96,bytes)and selector0x97fb5104. - settle
Return - Pays the unsettled delta up to
cumulativeAmountusing a valid voucher. Container type for the return parameters of thesettle((address,address,address,address,bytes32,address,bytes32),uint96,bytes)function. - topUp
Call - Adds deposit to a channel and cancels any pending close request.
Function with signature
topUp((address,address,address,address,bytes32,address,bytes32),uint96)and selector0xdc48471e. - topUp
Return - Adds deposit to a channel and cancels any pending close request.
Container type for the return parameters of the
topUp((address,address,address,address,bytes32,address,bytes32),uint96)function. - withdraw
Call - Withdraws the payer refund after the close grace period has elapsed.
Function with signature
withdraw((address,address,address,address,bytes32,address,bytes32))and selector0x41e2c664. - withdraw
Return - Withdraws the payer refund after the close grace period has elapsed.
Container type for the return parameters of the
withdraw((address,address,address,address,bytes32,address,bytes32))function.
Enums§
- ITIP20
Channel Reserve Calls - Container for all the
ITIP20ChannelReservefunction calls. - ITIP20
Channel Reserve Errors - Container for all the
ITIP20ChannelReservecustom errors. - ITIP20
Channel Reserve Events - Container for all the
ITIP20ChannelReserveevents.
Functions§
- new
- Creates a new wrapper around an on-chain
ITIP20ChannelReservecontract instance.