-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Withdraw helper contract to support collecting funds from channels #454
Conversation
b2c55a3
to
a75b1df
Compare
); | ||
|
||
// Call the staking contract to collect funds from this contract | ||
IStaking(collectData.staking).collect(_actualAmount, collectData.allocationID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this function reverts, the channel funds will be gone. We need to try-catch this call and provide a backup address the funds can be sent to (can even be the channel multisig address which is already part of the withdraw data).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collect function will only revert if: the allocation ID passed id 0x0 or invalid, it will then accept funds in any case.
My question is, why is that those funds will be lost? won't the collect call reverting make the transaction fail?
I based this on how the https://github.com/connext/vector-withdraw-helpers/blob/main/contracts/UniswapWithdrawHelper/UniswapWithdrawHelper.sol works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transaction will fail, but the funds are already signed out of the channel offchain, so they are effectively marked as "used".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhlsthrm and if the transfer to the channel is made instead, it will be credited to Bob, even though it might've being made by Alice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhlsthrm what happens if this transaction fails due to an out of gas exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhlsthrm and if the transfer to the channel is made instead, it will be credited to Bob, even though it might've being made by Alice?
Yes, if the transfer is made directly to the channel address, it will be credited to Bob. However, you can call depositAlice
. We might be able to program the logic to send to channel vs call depositAlice
into the helper itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhlsthrm what happens if this transaction fails due to an out of gas exception?
If it fails with hitting the gas limit on the transaction, you can resubmit the withdrawal commitment with a higher gas limit. It's only the case of a permanent failure that the funds are unrecoverable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect
f444407
to
4b74517
Compare
Rebased |
…rove call to return funds in case of revert
2bb44d5
to
7170fc0
Compare
) Introduces a contract called GRTWithdrawHelper. The main goal of this contract is to encode custom logic in the process of withdrawing funds from the Vector Channel Multisigs. The contract receives funds from a Channel Multisig, then it forwards them to the Staking contract related to an Allocation. - Add a withdraw helper contract to support collecting funds from channels. - Try catch revert on the Staking contract and return funds if that happens. - Add an explicit parties defined return address and wrap approve call to return funds in case of revert.
) Introduces a contract called GRTWithdrawHelper. The main goal of this contract is to encode custom logic in the process of withdrawing funds from the Vector Channel Multisigs. The contract receives funds from a Channel Multisig, then it forwards them to the Staking contract related to an Allocation. - Add a withdraw helper contract to support collecting funds from channels. - Try catch revert on the Staking contract and return funds if that happens. - Add an explicit parties defined return address and wrap approve call to return funds in case of revert.
Summary
Introduces a contract called
GRTWithdrawHelper
. The main goal of this contract is to encode custom logic in the process of withdrawing funds from the Vector Channel Multisigs. The contract receives funds from a Channel Multisig, then it forwards them to the Staking contract related to an Allocation.Features
execute(WithdrawData calldata wd, uint256 actualAmount)
is called by the Channel. For that to happen the Channel needs to transfer funds to the WithdrawHelper before execute is called.collect()
passing the proper allocationID and amount. The Staking contract will then pull the tokens.collect()
fails, the funds are returned to the channelAddress. This is important for Vector accounting of funds.Requirements
The parties must agree and sign the WithdrawalCommitment with that information to achieve proper execution of the withdrawals.
Exceptions
The following conditions will result in reverts of the execution:
Note: To avoid unexpected conditions in the Vector offchain logic, it is encouraged that the parties verify the WithdrawData does not revert by doing a call/estimateGas.
Handled Exceptions
These reverts are handled and will make the contract to return the funds to the channel address.
collect()
.Known Behaviour