-
Notifications
You must be signed in to change notification settings - Fork 270
fix(ovault-evm): override _sendLocal in VaultComposerSyncNative to deliver native ETH #1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,31 @@ contract VaultComposerSyncNative is VaultComposerSync, IVaultComposerSyncNative | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Unwrap WETH and transfer native ETH directly to recipient on the same chain | ||
| * @dev Overrides base _sendLocal which would incorrectly transfer WETH (ERC20) instead of native ETH | ||
| * @dev The base VaultComposerSync._sendLocal does `IERC20(ASSET_ERC20).safeTransfer(recipient, amount)` | ||
| * which transfers WETH. For the native variant, the vault redeems WETH but the recipient | ||
| * expects native ETH, so we must call WETH.withdraw() first. | ||
| * @param _oft The OFT contract address to determine asset vs share path | ||
| * @param _sendParam The parameters for the send operation | ||
| */ | ||
| function _sendLocal( | ||
| address _oft, | ||
| SendParam memory _sendParam, | ||
| address _refundAddress, | ||
| uint256 _msgValue | ||
| ) internal override virtual { | ||
| if (_oft == ASSET_OFT) { | ||
| /// @dev Vault redeems WETH; unwrap to native ETH before delivering to recipient | ||
| IWETH(ASSET_ERC20).withdraw(_sendParam.amountLD); | ||
| (bool success, ) = payable(address(uint160(uint256(_sendParam.to)))).call{ value: _sendParam.amountLD }(""); | ||
| if (!success) revert NativeTransferFailed(); | ||
| } else { | ||
| super._sendLocal(_oft, _sendParam, _refundAddress, _msgValue); | ||
| } | ||
|
Comment on lines
+103
to
+110
|
||
| } | ||
|
|
||
| /** | ||
| * @dev Unwrap WETH when sending to Stargate PoolNative and send via OFT | ||
| * @dev Overriden to unwrap WETH when sending to Stargate PoolNative | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_sendParam.tois decoded as a bytes32 “address” everywhere else viabytes32ToAddress()(seeVaultComposerSync._sendLocal). Here it’s converted withaddress(uint160(uint256(_sendParam.to))), which is inconsistent and can be error-prone if the bytes32 encoding ever changes or includes non-address data. Prefer using the samebytes32ToAddress()helper for consistency (and add the neededusing OFTComposeMsgCodec for bytes32;in this contract sinceusingdirectives aren’t inherited).