Skip to content

Commit

Permalink
feat(protocol): allow any address to withdraw token to the recipient …
Browse files Browse the repository at this point in the history
…address (taikoxyz#17843)
  • Loading branch information
dantaik authored Jul 25, 2024
1 parent 17d67d7 commit 3d89d24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/protocol/contracts/team/tokenunlock/TokenUnlock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ contract TokenUnlock is EssentialContract {
IERC20(resolve(LibStrings.B_TAIKO_TOKEN, false)).safeTransfer(_proverSet, _amount);
}

/// @notice Withdraws all withdrawable tokens.
/// @notice Withdraws tokens by the recipient.
/// @param _to The address the token will be sent to.
/// @param _amount The amount of tokens to withdraw.
function withdraw(
Expand All @@ -140,12 +140,17 @@ contract TokenUnlock is EssentialContract {
nonReentrant
{
if (_amount > amountWithdrawable()) revert NOT_WITHDRAWABLE();

emit TokenWithdrawn(_to, _amount);

IERC20(resolve(LibStrings.B_TAIKO_TOKEN, false)).safeTransfer(_to, _amount);
}

/// @notice Withdraws all tokens to the recipient address.
function withdraw() external nonReentrant {
uint256 amount = amountWithdrawable();
emit TokenWithdrawn(recipient, amount);
IERC20(resolve(LibStrings.B_TAIKO_TOKEN, false)).safeTransfer(recipient, amount);
}

function changeRecipient(address _newRecipient) external onlyRecipient {
if (_newRecipient == address(0) || _newRecipient == recipient) {
revert INVALID_PARAM();
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/deployments/mainnet-contract-logs-L1.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@
- impl: `0x035AFfC82612de31E9Db2259B9482D0Dd53B7819`
- logs:
- deployed @commit`bca493f` @tx`0x0a4a63715257b766ca06e7e87ee25088d557c460e50120208b31666c83fc68bc`
- todo:
- deploy a new version with `withdrawToRecipient` function
- upgrade `0x2Bc21D70BDe29a8E6576F7aCD979029058f2eeF9` with the new implementation

### prover_set

Expand Down

0 comments on commit 3d89d24

Please sign in to comment.