Skip to content

Commit 9c96580

Browse files
committed
native-pool-review (#1788)
Signed-off-by: shankar <[email protected]>
1 parent 7b12bab commit 9c96580

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

examples/ovault-evm/test/vault-sync/VaultComposerSync_ProxySend.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract VaultComposerSyncProxySendTest is VaultComposerSyncBaseTest {
2222
vm.deal(userA, 100 ether);
2323
}
2424

25-
function test_target_is_hub_reverts_when_msg_value_provided() public {
25+
function test_target_is_hub_does_not_revert_when_msg_value_provided() public {
2626
SendParam memory sendParam = SendParam(ARB_EID, addressToBytes32(userA), TOKENS_TO_SEND, 0, "", "", "");
2727
assetOFT_arb.mint(address(userA), TOKENS_TO_SEND);
2828
vault_arb.mint(address(userA), TOKENS_TO_SEND);

packages/ovault-evm/contracts/VaultComposerSync.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard {
398398
* @dev Internal function to validate the share token compatibility
399399
* @dev Validate part of the constructor in an overridable function due to differences in asset and OFT token
400400
* @return shareERC20 The address of the share ERC20 token
401-
* @notice Share token must be the vault itself
402-
* @notice Share OFT must be an adapter (approvalRequired() returns true)
401+
* @dev requirement Share token must be the vault itself
402+
* @dev requirement Share OFT must be an adapter (approvalRequired() returns true)
403403
*/
404404
function _initializeShareToken() internal virtual returns (address shareERC20) {
405405
shareERC20 = IOFT(SHARE_OFT).token();

packages/ovault-evm/contracts/VaultComposerSyncNative.sol

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { VaultComposerSync } from "./VaultComposerSync.sol";
1414
/**
1515
* @title Synchronous Vault Composer with Stargate NativePools as Asset and WETH as Share
1616
* @author LayerZero Labs (@shankars99)
17-
* @dev Extends VaultComposerSync with Pool-specific behavior such as oft.token wrapping
17+
* @dev Extends VaultComposerSync with Pool-specific behavior such as OFT token wrapping
1818
* @dev WETH is used as the asset token for the vault instead of native token (ETH)
19-
* @dev DepositAndSend and Deposit use asset token (WETH) instead of native token (ETH)
20-
* @dev DepositNativeAndSend allows for deposits with ETH
19+
* @dev `depositAndSend` uses asset token (WETH)
20+
* @dev `depositNativeAndSend` allows for deposits with ETH
2121
* @dev Redemptions always output the asset token (WETH)
2222
* @dev Compatible with ERC4626 vaults and requires Share OFT to be an adapter
2323
*/
@@ -43,7 +43,7 @@ contract VaultComposerSyncNative is VaultComposerSync, IVaultComposerSyncNative
4343
* @dev Reduction of ComposerNative into ComposerBase by wrapping ETH into WETH
4444
* @dev All internal logic handles WETH as the asset token making deposit symmetric to redemption
4545
* @dev The native token used here was sent during lzReceive from the Pool
46-
* @dev lzCompose calls comes from the Endpoint and are not affected by the wrapNative call
46+
@dev Inherits entry authorization from parent contract
4747
*/
4848
function lzCompose(
4949
address _composeSender, // The OFT used on refund, also the vaultIn token.
@@ -53,6 +53,7 @@ contract VaultComposerSyncNative is VaultComposerSync, IVaultComposerSyncNative
5353
bytes calldata _extraData
5454
) public payable virtual override {
5555
/// @dev Wrap ETH received during lzReceive into WETH
56+
/// @dev Conversion happens here to avoid running out of gas in the receive function
5657
if (_composeSender == ASSET_OFT) IWETH(ASSET_ERC20).deposit{ value: _message.amountLD() }();
5758

5859
/// @dev Since lzCompose is public, the msg.value called to pay the tx Fee is automatically forwarded
@@ -103,8 +104,8 @@ contract VaultComposerSyncNative is VaultComposerSync, IVaultComposerSyncNative
103104

104105
/// @dev Safe because this is the only function in VaultComposerSync that calls oft.send()
105106
if (_oft == ASSET_OFT) {
106-
/// @dev In deposit's lzReceive() we converted ETH to WETH.
107-
/// @dev Incase of redemption the vault outputs WETH.
107+
/// @dev In deposit's lzCompose() we converted ETH to WETH.
108+
/// @dev In a redemption, the vault outputs WETH.
108109
/// @dev So we always have WETH at this point which we unwrap to ETH for the Stargate Pool
109110
IWETH(ASSET_ERC20).withdraw(_sendParam.amountLD);
110111
/// @dev MsgValue passed to Stargate Pool is nativeFee + amountLD
@@ -132,6 +133,6 @@ contract VaultComposerSyncNative is VaultComposerSync, IVaultComposerSyncNative
132133

133134
receive() external payable virtual {
134135
/// @dev From ASSET_OFT for NativeOFT::lzReceive and from ASSET_ERC20 for WETH::withdraw
135-
if (msg.sender != ASSET_OFT && msg.sender != ASSET_ERC20) revert ETHTransferOnlyFromAssetOFT();
136+
if (msg.sender != ASSET_OFT && msg.sender != ASSET_ERC20) revert ETHTransferNotFromAsset();
136137
}
137138
}

packages/ovault-evm/contracts/interfaces/IVaultComposerSyncNative.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SendParam } from "@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol"
66
interface IVaultComposerSyncNative {
77
error AssetOFTTokenNotNative(); // 0xd61c4b4a
88
error AmountExceedsMsgValue(); // 0x0f971d59
9-
error ETHTransferOnlyFromAssetOFT(); // 0x61c07af9
9+
error ETHTransferNotFromAsset(); // 0x02cadbeb
1010

1111
/**
1212
* @notice Deposits Native token (ETH) from the caller into the vault and sends them to the recipient

packages/ovault-evm/test/vault-sync-stargate-pools/VaultComposerSyncSTG_Native.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ contract VaultComposerSyncSTG_NativeForkTest is VaultComposerSyncSTG_ERC20ForkTe
135135
assertFalse(success, "ETH transfer from non-pool address should fail");
136136

137137
// Check that the failure is due to the expected error
138-
bytes4 expectedErrorSignature = bytes4(keccak256("ETHTransferOnlyFromAssetOFT()"));
138+
bytes4 expectedErrorSignature = bytes4(keccak256("ETHTransferNotFromAsset()"));
139139
bytes4 actualErrorSignature = bytes4(returnData);
140-
assertEq(actualErrorSignature, expectedErrorSignature, "Should fail with ETHTransferOnlyFromAssetOFT error");
140+
assertEq(actualErrorSignature, expectedErrorSignature, "Should fail with ETHTransferNotFromAsset error");
141141

142142
assertEq(wethBalanceBefore, weth.balanceOf(address(ethComposer)), "WETH should not be wrapped");
143143
assertEq(address(ethComposer).balance, ethBalanceBefore, "ETH balance should remain unchanged");

packages/ovault-evm/test/vault-sync/VaultComposerSync_ProxySend.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ contract VaultComposerSyncProxySendTest is VaultComposerSyncBaseTest {
1414
super.setUp();
1515
}
1616

17-
function test_target_is_hub_reverts_when_msg_value_provided() public {
17+
function test_target_is_hub_does_not_revert_when_msg_value_provided() public {
1818
SendParam memory sendParam = SendParam(ARB_EID, addressToBytes32(userA), TOKENS_TO_SEND, 0, "", "", "");
1919
assetToken_arb.mint(address(userA), TOKENS_TO_SEND);
2020
vault_arb.mint(address(userA), TOKENS_TO_SEND);

0 commit comments

Comments
 (0)