diff --git a/src/core/ClientChainGateway.sol b/src/core/ClientChainGateway.sol index 4b0f6cfa..8443df86 100644 --- a/src/core/ClientChainGateway.sol +++ b/src/core/ClientChainGateway.sol @@ -180,10 +180,16 @@ contract ClientChainGateway is onlyCalledFromThis whenNotPaused { - (address token, uint256 newSupply) = _decodeTokenUint256(requestPayload, false); - IVault vault = _getVault(token); - uint256 tvlLimit = vault.getTvlLimit(); - bool success = tvlLimit <= newSupply && tvlLimitIncreasesInFlight[token] == 0; + (address token, uint256 newSupply) = _decodeTokenUint256(requestPayload, true); + bool success = false; + if (token == VIRTUAL_STAKED_ETH_ADDRESS) { + // native restaking has no tvl limit hence no need to limit the supply changes. + success = true; + } else { + IVault vault = _getVault(token); + uint256 tvlLimit = vault.getTvlLimit(); + success = tvlLimit <= newSupply && tvlLimitIncreasesInFlight[token] == 0; + } _sendMsgToExocore(Action.RESPOND, abi.encodePacked(lzNonce, success)); } diff --git a/src/core/ClientGatewayLzReceiver.sol b/src/core/ClientGatewayLzReceiver.sol index dace4738..ae778aa7 100644 --- a/src/core/ClientGatewayLzReceiver.sol +++ b/src/core/ClientGatewayLzReceiver.sol @@ -315,7 +315,7 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp onlyCalledFromThis whenNotPaused { - (address token, uint256 tvlLimit) = _decodeTokenUint256(requestPayload, true); + (address token, uint256 tvlLimit) = _decodeTokenUint256(requestPayload, false); isWhitelistedToken[token] = true; whitelistTokens.push(token); // since tokens cannot be removed from the whitelist, it is not possible for a vault @@ -335,7 +335,7 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp emit BootstrappedAlready(); } - function _decodeTokenUint256(bytes calldata payload, bool failIfWhitelisted) + function _decodeTokenUint256(bytes calldata payload, bool shouldBeWhitelisted) internal view returns (address, uint256) @@ -346,9 +346,14 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp // cannot happen since ExocoreGateway checks for this revert Errors.ZeroAddress(); } - if ((failIfWhitelisted) && (isWhitelistedToken[token])) { - // grave error, should never happen - revert Errors.ClientChainGatewayAlreadyWhitelisted(token); + if (isWhitelistedToken[token] != shouldBeWhitelisted) { + if (shouldBeWhitelisted) { + // we are receiving a request to edit the total supply of a non-whitelist token + revert Errors.TokenNotWhitelisted(token); + } else { + // we are receiving a request to whitelist a token that is already whitelisted + revert Errors.ClientChainGatewayAlreadyWhitelisted(token); + } } return (token, value); }