Skip to content

Commit

Permalink
precision fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MazyGio committed Jan 2, 2025
1 parent 10ded33 commit f016815
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
18 changes: 15 additions & 3 deletions contracts/src/instances/savings-usds-l2/SavingsUSDSL2Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,29 @@ abstract contract SavingsUSDSL2Base is HyperdriveBase {
address(_PSM),
_shareAmount
);

// Withdrawing amounts to swapping SUSDS back for USDS in the PSM.
amountWithdrawn = _PSM.swapExactOut(
amountWithdrawn = _PSM.swapExactIn(
address(_vaultSharesToken),
address(_baseToken),
_convertToBase(_shareAmount) - 1, // minus 1 because the PSM swap function rounds up.
_shareAmount,
_convertToBase(_shareAmount),
_destination,
0
);

return _convertToBase(amountWithdrawn);
return amountWithdrawn;

// amountWithdrawn = _PSM.swapExactOut(
// address(_vaultSharesToken),
// address(_baseToken),
// _convertToBase(_shareAmount) - 1, // minus 1 because the PSM swap function rounds up.
// _shareAmount,
// _destination,
// 0
// );

// return _convertToBase(amountWithdrawn);
}

/// @dev Process a withdrawal in vault shares and send the proceeds to the
Expand Down
11 changes: 3 additions & 8 deletions test/utils/InstanceTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,10 @@ abstract contract InstanceTest is HyperdriveTest {
uint256 traderBaseAfter,
uint256 traderSharesAfter
) = getTokenBalances(address(trader));
assertApproxEqAbs(
hyperdriveBaseAfter,
hyperdriveBalancesBefore.baseBalance,
config.verifyWithdrawalTolerance
);
assertApproxEqAbs(
assertEq(hyperdriveBaseAfter, hyperdriveBalancesBefore.baseBalance);
assertEq(
traderBaseAfter,
traderBalancesBefore.baseBalance + baseProceeds,
config.verifyWithdrawalTolerance
traderBalancesBefore.baseBalance + baseProceeds
);

// Ensure that the shares balances were updated correctly.
Expand Down

0 comments on commit f016815

Please sign in to comment.