Skip to content

Commit

Permalink
馃敟 escrow: drop internal _cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
itofarina committed Oct 9, 2023
1 parent 1725765 commit 61efaf9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-llamas-laugh.md
@@ -0,0 +1,5 @@
---
"@exactly/protocol": patch
---

馃敟 escrow: drop internal `_cancel`
12 changes: 6 additions & 6 deletions .gas-snapshot
Expand Up @@ -94,13 +94,13 @@ DebtPreviewerTest:testPreviewLeverageSameWETHAssetMultipleCollateralAndDebtWithM
DebtPreviewerTest:testPreviewMaxRatioWithdrawWithSameAssetLeverage() (gas: 1020516)
DebtPreviewerTest:testPreviewSameAssetInvalidLeverageShouldCapRatio() (gas: 910754)
EscrowedEXATest:testCancelExternalStreams() (gas: 452412)
EscrowedEXATest:testCancelExternalStreamsWithesEXACancel() (gas: 903899)
EscrowedEXATest:testCancelExternalStreamsWithesEXACancel() (gas: 903875)
EscrowedEXATest:testCancelFromStreamAndGetReserveBack() (gas: 453373)
EscrowedEXATest:testCancelFromStreamJustCreated() (gas: 406325)
EscrowedEXATest:testCancelShouldDeleteReserves() (gas: 472647)
EscrowedEXATest:testCancelShouldGiveReservesBack() (gas: 679641)
EscrowedEXATest:testCancelTwiceShouldRevert() (gas: 458917)
EscrowedEXATest:testCancelWithInvalidAccount() (gas: 349851)
EscrowedEXATest:testCancelShouldDeleteReserves() (gas: 472593)
EscrowedEXATest:testCancelShouldGiveReservesBack() (gas: 679587)
EscrowedEXATest:testCancelTwiceShouldRevert() (gas: 458839)
EscrowedEXATest:testCancelWithInvalidAccount() (gas: 349827)
EscrowedEXATest:testFakeTokenWithesEXARecipient() (gas: 932334)
EscrowedEXATest:testGrantTransferrerRoleAsAdmin() (gas: 45878)
EscrowedEXATest:testMint() (gas: 165075)
Expand All @@ -120,7 +120,7 @@ EscrowedEXATest:testTransferToTransferrer() (gas: 210419)
EscrowedEXATest:testVest() (gas: 348466)
EscrowedEXATest:testVestDisagreement() (gas: 181934)
EscrowedEXATest:testVestToAnother() (gas: 405112)
EscrowedEXATest:testVestToAnotherAndCancel() (gas: 491167)
EscrowedEXATest:testVestToAnotherAndCancel() (gas: 491113)
EscrowedEXATest:testVestWithPermitReserve() (gas: 458858)
EscrowedEXATest:testVestZero() (gas: 20986)
EscrowedEXATest:testWithdrawFromStreamAndGetReserveBack() (gas: 331155)
Expand Down
12 changes: 2 additions & 10 deletions contracts/periphery/EscrowedEXA.sol
Expand Up @@ -131,16 +131,6 @@ contract EscrowedEXA is ERC20VotesUpgradeable, AccessControlUpgradeable {
/// @return streamsReserves Amount of EXA in reserves that is returned to the cancelled stream holders.
function cancel(uint256[] memory streamIds) external returns (uint256 streamsReserves) {
uint128 refundableAmount;
(streamsReserves, refundableAmount) = _cancel(streamIds);
_mint(msg.sender, refundableAmount);
exa.safeTransfer(msg.sender, streamsReserves);
}

/// @notice Cancels vesting streams and withdraws the remaining EXA.
/// @param streamIds Array of streamIds to cancel.
/// @return streamsReserves Amount of EXA in reserves that is returned to the cancelled streams holder.
/// @dev the caller must be the recepient of the streamIds.
function _cancel(uint256[] memory streamIds) internal returns (uint256 streamsReserves, uint128 refundableAmount) {
for (uint256 i = 0; i < streamIds.length; ++i) {
uint256 streamId = streamIds[i];
checkStream(streamId);
Expand All @@ -152,6 +142,8 @@ contract EscrowedEXA is ERC20VotesUpgradeable, AccessControlUpgradeable {
sablier.cancel(streamId);
}
emit Cancel(msg.sender, streamIds);
_mint(msg.sender, refundableAmount);
exa.safeTransfer(msg.sender, streamsReserves);
}

/// @notice Withdraws the EXA from the vesting streamIds. If a stream is depleted, its reserve is returned.
Expand Down

0 comments on commit 61efaf9

Please sign in to comment.