Skip to content

Commit

Permalink
increases pool TWAP in autoredemption, and uses amount of USDs out of…
Browse files Browse the repository at this point in the history
… swap, rather than contract balance
  • Loading branch information
ewansheldon committed Jan 2, 2025
1 parent 3c5e136 commit a8cdc77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/AutoRedemption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract AutoRedemption is AutomationCompatibleInterface, FunctionsClient, Confi

uint32 private constant MAX_REQ_GAS = 300000;
uint160 private constant TARGET_PRICE = 79228162514264337593543;
uint32 private constant TWAP_INTERVAL = 300;
uint32 private constant TWAP_INTERVAL = 1800;

bytes32 private lastRequestId;
bytes32 private immutable donID;
Expand Down
7 changes: 3 additions & 4 deletions contracts/SmartVaultV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ contract SmartVaultV4 is ISmartVault, IRedeemable {
address _collateralToken,
bytes memory _swapPath,
uint256 _USDsTargetAmount
) private {
) private returns (uint256 _amountOut) {
uint256 _amountIn = calculateAmountIn(_quoterAddress, _collateralToken, _swapPath, _USDsTargetAmount);
IERC20(_collateralToken).safeIncreaseAllowance(_swapRouterAddress, _amountIn);
ISwapRouter(_swapRouterAddress).exactInput(
_amountOut = ISwapRouter(_swapRouterAddress).exactInput(
ISwapRouter.ExactInputParams({
path: _swapPath,
recipient: address(this),
Expand Down Expand Up @@ -366,8 +366,7 @@ contract SmartVaultV4 is ISmartVault, IRedeemable {
_collateralToken = ISmartVaultManager(manager).weth();
IWETH(_collateralToken).deposit{value: address(this).balance}();
}
swapCollateral(_swapRouterAddress, _quoterAddress, _collateralToken, _swapPath, _USDsTargetAmount);
_redeemed = USDs.balanceOf(address(this));
uint256 _redeemed = swapCollateral(_swapRouterAddress, _quoterAddress, _collateralToken, _swapPath, _USDsTargetAmount);
minted -= _redeemed;
USDs.burn(address(this), _redeemed);
if (_hypervisor != address(0) && _withdrawn > 0) {
Expand Down

0 comments on commit a8cdc77

Please sign in to comment.