@@ -76,9 +76,10 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard {
7676 /// @dev burn() on tokens when a user sends changes totalSupply() which the asset:share ratio depends on.
7777 if (! IOFT (SHARE_OFT).approvalRequired ()) revert ShareOFTNotAdapter (SHARE_OFT);
7878
79- /// @dev Approve the vault to spend the share and asset tokens held by this contract
80- IERC20 (SHARE_ERC20).approve (_vault, type (uint256 ).max);
79+ /// @dev Approve the vault to spend the asset tokens held by this contract
8180 IERC20 (ASSET_ERC20).approve (_vault, type (uint256 ).max);
81+ /// @dev Approving the vault for the share erc20 is not required when the vault is the share erc20
82+ // IERC20(SHARE_ERC20).approve(_vault, type(uint256).max);
8283
8384 /// @dev Approve the share adapter with the share tokens held by this contract
8485 IERC20 (SHARE_ERC20).approve (_shareOFT, type (uint256 ).max);
@@ -90,26 +91,26 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard {
9091 * @notice Handles LayerZero compose operations for vault transactions with automatic refund functionality
9192 * @dev This composer is designed to handle refunds to an EOA address and not a contract
9293 * @dev Any revert in handleCompose() causes a refund back to the src EXCEPT for InsufficientMsgValue
93- * @param _composeCaller The OFT contract address used for refunds, must be either ASSET_OFT or SHARE_OFT
94+ * @param _composeSender The OFT contract address used for refunds, must be either ASSET_OFT or SHARE_OFT
9495 * @param _guid LayerZero's unique tx id (created on the source tx)
9596 * @param _message Decomposable bytes object into [composeHeader][composeMessage]
9697 */
9798 function lzCompose (
98- address _composeCaller , // The OFT used on refund, also the vaultIn token.
99+ address _composeSender , // The OFT used on refund, also the vaultIn token.
99100 bytes32 _guid ,
100101 bytes calldata _message , // expected to contain a composeMessage = abi.encode(SendParam hopSendParam,uint256 minMsgValue)
101102 address /*_executor*/ ,
102103 bytes calldata /*_extraData*/
103104 ) external payable virtual override {
104105 if (msg .sender != ENDPOINT) revert OnlyEndpoint (msg .sender );
105- if (_composeCaller != ASSET_OFT && _composeCaller != SHARE_OFT) revert OnlyValidComposeCaller (_composeCaller );
106+ if (_composeSender != ASSET_OFT && _composeSender != SHARE_OFT) revert OnlyValidComposeCaller (_composeSender );
106107
107108 bytes32 composeFrom = _message.composeFrom ();
108109 uint256 amount = _message.amountLD ();
109110 bytes memory composeMsg = _message.composeMsg ();
110111
111112 /// @dev try...catch to handle the compose operation. if it fails we refund the user
112- try this .handleCompose { value: msg .value }(_composeCaller , composeFrom, composeMsg, amount) {
113+ try this .handleCompose { value: msg .value }(_composeSender , composeFrom, composeMsg, amount) {
113114 emit Sent (_guid);
114115 } catch (bytes memory _err ) {
115116 /// @dev A revert where the msg.value passed is lower than the min expected msg.value is handled separately
@@ -120,7 +121,7 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard {
120121 }
121122 }
122123
123- _refund (_composeCaller , _message, amount, tx .origin );
124+ _refund (_composeSender , _message, amount, tx .origin );
124125 emit Refunded (_guid);
125126 }
126127 }
@@ -272,23 +273,25 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard {
272273 /**
273274 * @notice Quotes the send operation for the given OFT and SendParam
274275 * @dev Revert on slippage will be thrown by the OFT and not _assertSlippage
275- * @param _oft The OFT contract address to quote
276+ * @param _targetOFT The OFT contract address to quote
276277 * @param _vaultInAmount The amount of tokens to send to the vault
277278 * @param _sendParam The parameters for the send operation
278279 * @return MessagingFee The estimated fee for the send operation
279280 * @dev This function can be overridden to implement custom quoting logic
280281 */
281282 function quoteSend (
282- address _oft ,
283+ address _targetOFT ,
283284 uint256 _vaultInAmount ,
284285 SendParam memory _sendParam
285286 ) external view virtual returns (MessagingFee memory ) {
286- if (_oft == ASSET_OFT) {
287- _sendParam.amountLD = VAULT. previewDeposit (_vaultInAmount);
288- } else {
287+ /// @dev When quoting the asset OFT, the function input is shares and the SendParam.amountLD into quoteSend() should be assets (and vice versa)
288+
289+ if (_targetOFT == ASSET_OFT) {
289290 _sendParam.amountLD = VAULT.previewRedeem (_vaultInAmount);
291+ } else {
292+ _sendParam.amountLD = VAULT.previewDeposit (_vaultInAmount);
290293 }
291- return IOFT (_oft ).quoteSend (_sendParam, false );
294+ return IOFT (_targetOFT ).quoteSend (_sendParam, false );
292295 }
293296
294297 /**
@@ -304,7 +307,7 @@ contract VaultComposerSync is IVaultComposerSync, ReentrancyGuard {
304307 /// @dev Can do this because _oft is validated before this function is called
305308 address erc20 = _oft == ASSET_OFT ? ASSET_ERC20 : SHARE_ERC20;
306309
307- if (msg .value > 0 ) revert InsufficientMsgValue ( 0 , msg . value );
310+ if (msg .value > 0 ) revert NoMsgValueExpected ( );
308311 IERC20 (erc20).safeTransfer (_sendParam.to.bytes32ToAddress (), _sendParam.amountLD);
309312 } else {
310313 // crosschain send
0 commit comments