Skip to content

Commit

Permalink
Merge pull request #673 from ionicprotocol/feat/rescue-tokens-levered…
Browse files Browse the repository at this point in the history
…-positions

Fn to rescue tokens from levered positions
  • Loading branch information
vminkov authored Oct 24, 2024
2 parents 6e55000 + ed86436 commit f1cd736
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ contract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {

error OnlyWhenClosed();
error NotPositionOwner();
error OnlyFactoryOwner();
error AssetNotRescuable();
error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);

error ConvertFundsFailed();
Expand Down Expand Up @@ -167,6 +169,13 @@ contract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {
}
}

function rescueTokens(IERC20Upgradeable asset) external {
if (msg.sender != factory.owner()) revert OnlyFactoryOwner();
if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();

asset.transfer(positionOwner, asset.balanceOf(address(this)));
}

function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {
IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);
(address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));
Expand Down

0 comments on commit f1cd736

Please sign in to comment.