Skip to content

Commit 8e55643

Browse files
authored
Merge pull request #184 from Gearbox-protocol/upshift-fix
fix: upshift gateway correctly handles lagDuration == 0
2 parents 6d3abbb + bdc69ec commit 8e55643

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

contracts/helpers/upshift/UpshiftVaultGateway.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract UpshiftVaultGateway is ReentrancyGuardTrait, IUpshiftVaultGateway {
2222
using SafeERC20 for IERC20;
2323

2424
bytes32 public constant override contractType = "GATEWAY::UPSHIFT_VAULT";
25-
uint256 public constant override version = 3_10;
25+
uint256 public constant override version = 3_11;
2626

2727
address public immutable upshiftVault;
2828

@@ -54,15 +54,16 @@ contract UpshiftVaultGateway is ReentrancyGuardTrait, IUpshiftVaultGateway {
5454
revert("UpshiftVaultGateway: user has a pending redeem");
5555
}
5656

57-
(uint256 year, uint256 month, uint256 day, uint256 claimableTimestamp) =
58-
IUpshiftVault(upshiftVault).getWithdrawalEpoch();
57+
(uint256 year, uint256 month, uint256 day,) = IUpshiftVault(upshiftVault).getWithdrawalEpoch();
5958

60-
uint256 assets = IERC4626(upshiftVault).previewRedeem(shares);
59+
(uint256 assets, uint256 claimableTimestamp) = IUpshiftVault(upshiftVault).requestRedeem({
60+
shares: shares,
61+
receiverAddr: address(this),
62+
holderAddr: msg.sender
63+
});
6164

6265
pendingRedeems[msg.sender] =
6366
PendingRedeem({claimableTimestamp: claimableTimestamp, assets: assets, year: year, month: month, day: day});
64-
65-
IUpshiftVault(upshiftVault).requestRedeem({shares: shares, receiverAddr: address(this), holderAddr: msg.sender});
6667
}
6768

6869
function claim(uint256 amount) external nonReentrant {

contracts/integrations/upshift/IUpshiftVault.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
pragma solidity ^0.8.10;
33

44
interface IUpshiftVault {
5-
function requestRedeem(uint256 shares, address receiverAddr, address holderAddr) external;
5+
function requestRedeem(uint256 shares, address receiverAddr, address holderAddr)
6+
external
7+
returns (uint256 assets, uint256 claimableTimestamp);
68

79
function claim(uint256 year, uint256 month, uint256 day, address receiverAddr) external;
810

0 commit comments

Comments
 (0)