@@ -16,6 +16,8 @@ import { IERC4626 } from "../lib/openzeppelin-contracts/contracts/interfaces/IER
1616
1717import { IPSM3 } from "spark-psm/src/interfaces/IPSM3.sol " ;
1818
19+ import { LayerZeroLib } from "./libraries/LayerZeroLib.sol " ;
20+
1921import { IALMProxy } from "./interfaces/IALMProxy.sol " ;
2022import { ICCTPLike } from "./interfaces/CCTPInterfaces.sol " ;
2123import { IRateLimits } from "./interfaces/IRateLimits.sol " ;
@@ -68,7 +70,7 @@ contract ForeignController is ReentrancyGuard, AccessControlEnumerable {
6870 bytes32 public constant LIMIT_AAVE_DEPOSIT = keccak256 ("LIMIT_AAVE_DEPOSIT " );
6971 bytes32 public constant LIMIT_AAVE_WITHDRAW = keccak256 ("LIMIT_AAVE_WITHDRAW " );
7072 bytes32 public constant LIMIT_ASSET_TRANSFER = keccak256 ("LIMIT_ASSET_TRANSFER " );
71- bytes32 public constant LIMIT_LAYERZERO_TRANSFER = keccak256 ( " LIMIT_LAYERZERO_TRANSFER " ) ;
73+ bytes32 public constant LIMIT_LAYERZERO_TRANSFER = LayerZeroLib. LIMIT_LAYERZERO_TRANSFER;
7274 bytes32 public constant LIMIT_PSM_DEPOSIT = keccak256 ("LIMIT_PSM_DEPOSIT " );
7375 bytes32 public constant LIMIT_PSM_WITHDRAW = keccak256 ("LIMIT_PSM_WITHDRAW " );
7476 bytes32 public constant LIMIT_SPARK_VAULT_TAKE = keccak256 ("LIMIT_SPARK_VAULT_TAKE " );
@@ -301,45 +303,15 @@ contract ForeignController is ReentrancyGuard, AccessControlEnumerable {
301303 payable
302304 nonReentrant
303305 onlyRole (RELAYER)
304- rateLimited (
305- keccak256 (abi.encode (LIMIT_LAYERZERO_TRANSFER, oftAddress, destinationEndpointId)),
306- amount
307- )
308306 {
309- bytes32 recipient = layerZeroRecipients[destinationEndpointId];
310-
311- require (recipient != bytes32 (0 ), "FC/recipient-not-set " );
312-
313- // NOTE: Full integration testing of this logic is not possible without OFTs with
314- // approvalRequired == true. Add integration testing for this case before
315- // using in production.
316- if (ILayerZero (oftAddress).approvalRequired ()) {
317- _approve (ILayerZero (oftAddress).token (), oftAddress, amount);
318- }
319-
320- bytes memory options = OptionsBuilder.newOptions ().addExecutorLzReceiveOption (200_000 , 0 );
321-
322- SendParam memory sendParams = SendParam ({
323- dstEid : destinationEndpointId,
324- to : recipient,
325- amountLD : amount,
326- minAmountLD : 0 ,
327- extraOptions : options,
328- composeMsg : "" ,
329- oftCmd : ""
307+ LayerZeroLib.transferTokenLayerZero ({
308+ proxy : proxy,
309+ rateLimits : rateLimits,
310+ oftAddress : oftAddress,
311+ amount : amount,
312+ destinationEndpointId : destinationEndpointId,
313+ layerZeroRecipient : layerZeroRecipients[destinationEndpointId]
330314 });
331-
332- // Query the min amount received on the destination chain and set it.
333- ( ,, OFTReceipt memory receipt ) = ILayerZero (oftAddress).quoteOFT (sendParams);
334- sendParams.minAmountLD = receipt.amountReceivedLD;
335-
336- MessagingFee memory fee = ILayerZero (oftAddress).quoteSend (sendParams, false );
337-
338- proxy.doCallWithValue {value: fee.nativeFee}(
339- oftAddress,
340- abi.encodeCall (ILayerZero.send, (sendParams, fee, address (proxy))),
341- fee.nativeFee
342- );
343315 }
344316
345317 /**********************************************************************************************/
0 commit comments