Withdraw helper contract to support collecting funds from Vector channels

This proposal is to deploy a new peripheral contract to connect Vector state channels with the core protocol. For this contract to work the Council will need to set its address as asset holder in the Staking contract.


Vector state channels are contracts that hold funds used as collateral for consumer-to-indexer payments. When an indexer closes an allocation, both parties sign a withdrawal commitment to transfer the query fees accumulated for the allocation back to the network. Vector, by default, supports plain transfers from the channel to any destination defined in the withdrawal commitment. In the case of the Graph Network, all funds should be collected by calling the collect() function in the Staking contract. For the purpose of calling custom logic when transferring from channels, Vector supports using a WithdrawHelper contract. In this proposal we describe the implementation of such a contract for connecting a Vector withdrawal transfer to the Graph Network.


A contract called GRTWithdrawHelper that extends the base WithdrawHelper provided by the Vector framework. This contract has a function execute(WithdrawData _wd, uint256 _actualAmount) external that is called in the same transaction when the indexer withdraw funds from the channel. The execute function evaluates the validity of the WithdrawData struct, and then approve and transfer the received funds to the Staking contract by calling collect() .

This contract does not hold funds, it just forward the received funds from the Vector channels in the context of an atomic transaction.


A candidate contract was implemented in this PR:

The contract was audited by ChainSafe and deployed and tested in Rinkeby:

A GIP will be published with additional information on Radicle.