WETHNativeConverter
Inherits: NativeConverter
Author: See https://github.com/agglayer/vault-bridge
State Variables
_WETH_NATIVE_CONVERTER_STORAGE
The storage slot at which WETHNativeConverter storage starts, following the EIP-7201 standard.
Calculated as keccak256(abi.encode(uint256(keccak256("agglayer.vault-bridge.WETHNativeConverter.storage")) - 1)) & ~bytes32(uint256(0xff))
.
bytes32 private constant _WETH_NATIVE_CONVERTER_STORAGE =
hex"f9565ea242552c2a1a216404344b0c8f6a3093382a21dd5bd6f5dc2ff1934d00";
Functions
onlyIfGasTokenIsEth
modifier onlyIfGasTokenIsEth();
constructor
constructor();
initialize
function initialize(
address owner_,
address customToken_,
address underlyingToken_,
address lxlyBridge_,
uint32 layerXNetworkId_,
uint256 nonMigratableBackingPercentage_,
address migrationManager_,
uint256 nonMigratableGasBackingPercentage_
) external initializer;
nonMigratableGasBackingPercentage
function nonMigratableGasBackingPercentage() public view returns (uint256);
_getWETHNativeConverterStorage
function _getWETHNativeConverterStorage() private pure returns (WETHNativeConverterStorage storage $);
migratableGasBacking
function migratableGasBacking() public view returns (uint256);
migrateGasBackingToLayerX
It is known that this can lead to WETH not being able to perform withdrawals, because of a lack of gas backing.
However, this is acceptable, because WETH is a vault backed token so its backing should actually be staked.
Users can still bridge WETH back to Layer X to receive wETH or ETH.
This special function allows the NativeConverter owner to migrate the gas backing of the WETH Custom Token
It simply takes the amount of gas token from the WETH contract
and performs the migration using a special CrossNetworkInstruction called _1_WRAP_GAS_TOKEN_AND_COMPLETE_MIGRATION
It instructs vbETH on Layer X to first wrap the gas token and then deposit it to complete the migration.
function migrateGasBackingToLayerX(uint256 amount)
external
whenNotPaused
onlyIfGasTokenIsEth
onlyRole(MIGRATOR_ROLE)
nonReentrant;
receive
receive() external payable whenNotPaused onlyIfGasTokenIsEth;
setNonMigratableGasBackingPercentage
function setNonMigratableGasBackingPercentage(uint256 nonMigratableGasBackingPercentage_)
external
onlyRole(DEFAULT_ADMIN_ROLE)
nonReentrant;
Events
NonMigratableGasBackingPercentageSet
event NonMigratableGasBackingPercentageSet(uint256 nonMigratableGasBackingPercentage_);
Errors
FunctionNotSupportedOnThisNetwork
error FunctionNotSupportedOnThisNetwork();
InvalidNonMigratableGasBackingPercentage
error InvalidNonMigratableGasBackingPercentage();
Structs
WETHNativeConverterStorage
Storage of WETHNativeConverter contract.
It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions when using with upgradeable contracts.
Note: storage-location: erc7201:agglayer.vault-bridge.WETHNativeConverter.storage
struct WETHNativeConverterStorage {
WETH _weth;
bool _gasTokenIsEth;
uint256 nonMigratableGasBackingPercentage;
}