Skip to content
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

feat(ccip): CCIPFacet v1.0.0 #542

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a831dc1
Generate boilerplate
ezynda3 Sep 18, 2023
a4aeab1
Add configuration
ezynda3 Sep 20, 2023
bcaf49a
Merge branch 'main' of github.com:lifinance/contracts into LF-4961-Im…
ezynda3 Sep 21, 2023
2de777e
Merge branch 'main' of github.com:lifinance/contracts into LF-4961-Im…
ezynda3 Sep 22, 2023
77e78ef
Implement CCIP business logic
ezynda3 Sep 22, 2023
3dfae65
Start implementing tests
ezynda3 Sep 25, 2023
fcd85ef
Formatting
ezynda3 Sep 25, 2023
0ec4b5a
Update tests
ezynda3 Sep 25, 2023
041774f
Merge branch 'main' of github.com:lifinance/contracts into LF-4961-Im…
ezynda3 Sep 28, 2023
657c5d8
Add convenience functions
ezynda3 Sep 29, 2023
acd60af
Update deploy scripts
ezynda3 Sep 29, 2023
7727181
Deploy to staging
ezynda3 Sep 29, 2023
6d5ec6f
Create demo script
ezynda3 Oct 3, 2023
9da5958
Add basic documentation
ezynda3 Oct 3, 2023
7376af6
Update demo
ezynda3 Oct 24, 2023
d24ebee
Merge branch 'main' into LF-4961-Implementing-CCIP-support
ezynda3 Oct 25, 2023
972b7b2
Add missing URI
ezynda3 Oct 25, 2023
1d3998f
Merge branch 'main' into LF-4961-Implementing-CCIP-support
ezynda3 Oct 27, 2023
bd5c154
Implement destination calls for CCIP
ezynda3 Oct 27, 2023
bffeaf1
Update demo
ezynda3 Oct 27, 2023
05d6a18
Remove unneeded payload args
ezynda3 Oct 30, 2023
650ae7a
Update demo script
ezynda3 Oct 30, 2023
c3470e4
Redeploy to staging
ezynda3 Oct 30, 2023
fa77981
Revert back to previous version
ezynda3 Oct 30, 2023
f9211b6
Update demo script
ezynda3 Oct 30, 2023
96dc26f
Merge branch 'main' of github.com:lifinance/contracts into LF-4961-Im…
ezynda3 Nov 10, 2023
24806fb
Merge branch 'main' into LF-4961-Implementing-CCIP-support
ezynda3 Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
ezynda3 committed Sep 25, 2023

Verified

This commit was signed with the committer’s verified signature.
sourabhxyz Sourabh
commit 0ec4b5a1fff4d53fdebd5c241ee6150d4b4e4a01
12 changes: 9 additions & 3 deletions src/Facets/CCIPFacet.sol
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ pragma solidity 0.8.17;

import { ILiFi } from "../Interfaces/ILiFi.sol";
import { LibDiamond } from "../Libraries/LibDiamond.sol";
import { LibAsset } from "../Libraries/LibAsset.sol";
import { LibAsset, IERC20 } from "../Libraries/LibAsset.sol";
import { LibSwap } from "../Libraries/LibSwap.sol";
import { ReentrancyGuard } from "../Helpers/ReentrancyGuard.sol";
import { SwapperV2 } from "../Helpers/SwapperV2.sol";
@@ -145,14 +145,20 @@ contract CCIPFacet is ILiFi, ReentrancyGuard, SwapperV2, Validatable {
});

Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
receiver: abi.encode(_bridgeData),
receiver: abi.encode(_bridgeData.receiver),
data: _ccipData.callData,
tokenAmounts: amounts,
feeToken: address(0),
extraArgs: _ccipData.extraArgs
});

routerClient.ccipSend(
LibAsset.maxApproveERC20(
IERC20(_bridgeData.sendingAssetId),
address(routerClient),
_bridgeData.minAmount
);

routerClient.ccipSend{ value: msg.value }(
getCCIPChainSelector(_bridgeData.destinationChainId),
message
);
22 changes: 7 additions & 15 deletions test/solidity/Facets/CCIPFacet.t.sol
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ contract CCIPFacetTest is Test, DiamondTest {
address internal constant CCIP_TEST_TOKEN_ADDRESS =
0x79a4Fc27f69323660f5Bfc12dEe21c3cC14f5901; // CCIP Burn & Mint Test Token
address internal constant ROUTER_CLIENT =
0x677311Fd2cCc511Bbc0f581E8d9a07B033D5E840;
0x9527E2d01A3064ef6b50c1Da1C0cC523803BCFF2;
uint256 internal constant DSTCHAIN_ID = 11155111; // Sepolia

// -----
@@ -186,21 +186,15 @@ contract CCIPFacetTest is Test, DiamondTest {
10_000 * 10 ** ccipTestToken.decimals()
);

ccipFacet.startBridgeTokensViaCCIP(validBridgeData, validCCIPData);
ccipFacet.startBridgeTokensViaCCIP{ value: 0.1 ether }(
validBridgeData,
validCCIPData
);
}

function testCanSwapAndBridgeTokens() public {
deal(address(usdc), address(this), 10_000 * 10 ** usdc.decimals());
usdc.approve(address(ccipFacet), 10_000 * 10 ** usdc.decimals());
deal(
address(ccipTestToken),
address(this),
10 * 10 ** ccipTestToken.decimals()
);

ccipTestToken.approve(
address(ccipFacet),
10_000 * 10 ** ccipTestToken.decimals()
);

uint256 inAmount = 10_000 * 10 ** usdc.decimals();
uint256 outAmount = 10_000 * 10 ** ccipTestToken.decimals();
@@ -226,12 +220,10 @@ contract CCIPFacetTest is Test, DiamondTest {
ILiFi.BridgeData memory bridgeData = validBridgeData;
bridgeData.hasSourceSwaps = true;

ccipFacet.swapAndStartBridgeTokensViaCCIP(
ccipFacet.swapAndStartBridgeTokensViaCCIP{ value: 0.1 ether }(
bridgeData,
swapData,
validCCIPData
);

vm.stopPrank();
}
}