@@ -98,21 +98,17 @@ contract MigrationRelease is Ownable {
9898
9999 instantClaimTime[leaf] = block .timestamp ;
100100 totalReleased += instantAmount;
101-
102- // Logic to release funds instantly
103-
104- (bool res , ) = payable (_recipient).call {value: instantAmount}("" );
105- require (res, "Transfer failed " );
106101 emit ReleasedInstant (_recipient, instantAmount, block .timestamp );
107- }
108102
103+ transferFunds (_recipient, instantAmount);
104+ }
109105
110106 /// @notice Allows users to release their vested tokens
111- /// @param _recipient The address of the recipient
107+ /// @param _recipient The address of the recipient
112108 /// @param _amount The amount of tokens to release
113109 /// @param _id The unique identifier for the release
114110 /// @dev checks if the recipient is whitelisted and has not claimed before
115- /// @dev checks if the vesting period has passed
111+ /// @dev checks if the vesting period has passed
116112 /// @dev calculates the vested amount based on the VESTING_RATIO
117113 /// @dev updates the claimedvested mapping and totalReleased variable
118114 /// @dev transfers the vested amount to the recipient, reverting if the transfer fails
@@ -138,10 +134,19 @@ contract MigrationRelease is Ownable {
138134 uint vestedAmount = _amount * VESTING_RATIO; // Vested amount is 10 times the amount
139135 claimedvested[leaf] = true ;
140136 totalReleased += vestedAmount;
141- // Logic to release vested funds
142- (bool res , ) = payable (_recipient).call {value: vestedAmount}("" );
143- require (res, "Transfer failed " );
144137 emit ReleasedVested (_recipient, vestedAmount, block .timestamp );
138+ transferFunds (_recipient, vestedAmount);
139+ }
140+
141+ function transferFunds (
142+ address _recipient ,
143+ uint _amount
144+ ) internal {
145+ if (address (this ).balance < _amount) {
146+ revert ("Insufficient balance " );
147+ }
148+ (bool res , ) = payable (_recipient).call {value: _amount}("" );
149+ require (res, "Transfer failed " );
145150 }
146151
147152 function verifyAddress (
0 commit comments