Skip to content

Commit

Permalink
Block old RUNE token on Mainnet [ThorSwapFacet v1.2.1] (#913)
Browse files Browse the repository at this point in the history
* block old RUNE token on Mainnet

* bump version
  • Loading branch information
ezynda3 authored Jan 9, 2025
1 parent f31c9d1 commit a7ff569
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Facets/ThorSwapFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import { ContractCallNotAllowed } from "../Errors/GenericErrors.sol";
/// @title ThorSwap Facet
/// @author Li.Finance (https://li.finance)
/// @notice Provides functionality for bridging through ThorSwap
/// @custom:version 1.2.0
/// @custom:version 1.2.1
contract ThorSwapFacet is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
address private immutable thorchainRouter;

address private constant DEPRECATED_RUNE =
0x3155BA85D5F96b2d030a4966AF206230e46849cb;

/// @notice The struct for the ThorSwap data.
/// @param vault The Thorchain vault address
/// @param memo The memo to send to Thorchain for the swap
Expand All @@ -27,6 +30,8 @@ contract ThorSwapFacet is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
uint256 expiration;
}

error DeprecatedToken();

/// @notice Initializes the ThorSwap contract
constructor(address _thorchainRouter) {
thorchainRouter = _thorchainRouter;
Expand Down Expand Up @@ -87,6 +92,12 @@ contract ThorSwapFacet is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
ILiFi.BridgeData memory _bridgeData,
ThorSwapData calldata _thorSwapData
) internal {
if (
block.chainid == 1 && _bridgeData.sendingAssetId == DEPRECATED_RUNE
) {
revert DeprecatedToken();
}

IERC20 sendingAssetId = IERC20(_bridgeData.sendingAssetId);
bool isNative = LibAsset.isNativeAsset(address(sendingAssetId));

Expand Down
23 changes: 23 additions & 0 deletions test/solidity/Facets/ThorSwapFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ contract ThorSwapFacetTest is TestBaseFacet {
vm.label(THORCHAIN_ROUTER, "THORCHAIN_ROUTER");
}

function testBase_Revert_SendingDeprecatedRune() public {
// Set bridgeData to use DEPRECATED_RUNE address
address DEPRECATED_RUNE = 0x3155BA85D5F96b2d030a4966AF206230e46849cb;
bridgeData.sendingAssetId = DEPRECATED_RUNE;

// Deal DEPRECATED_RUNE tokens to the user
deal(DEPRECATED_RUNE, USER_SENDER, bridgeData.minAmount);

vm.startPrank(USER_SENDER);
// Approve tokens for the contract
ERC20(DEPRECATED_RUNE).approve(
address(thorSwapFacet),
bridgeData.minAmount
);

vm.expectRevert(ThorSwapFacet.DeprecatedToken.selector);
thorSwapFacet.startBridgeTokensViaThorSwap(
bridgeData,
validThorSwapData
);
vm.stopPrank();
}

function initiateBridgeTxWithFacet(bool isNative) internal override {
if (isNative) {
thorSwapFacet.startBridgeTokensViaThorSwap{
Expand Down

0 comments on commit a7ff569

Please sign in to comment.