Skip to content

Commit

Permalink
Debridge DLN Facet (Version 1.0.0) [DeBridgeDlnFacet v1.0.0] (#827)
Browse files Browse the repository at this point in the history
* Move DeBridgeDLNFacet from archive

* Move docs from archive and update README

* improve code coverage

* improve code coverage

* Fix opbnb

* Update variable naming

* Add mappings

* Update demo

* fix tests

* Check for empty non EVM address

* Various fixes

* Add referral code

* explicitly set orderAuthorityDst

* Fix referral code mismatch

* Always check for empty receiver address

* Remove unneeded parameter

* Update audit log

* sort audited contracts
  • Loading branch information
ezynda3 authored Jan 8, 2025
1 parent 9e427a1 commit 7c9f170
Show file tree
Hide file tree
Showing 16 changed files with 584 additions and 56 deletions.
13 changes: 0 additions & 13 deletions archive/scripts/Deploy/UpdateDeBridgeDlnFacet.s.sol

This file was deleted.

11 changes: 11 additions & 0 deletions audit/auditLog.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
"auditReportPath": "./audit/reports/2024.12.03_LiFiDexAggregator.pdf",
"auditCommitHash": "8a34562c912b5b19c919bb95338655c944428af5"
},
"audit20241205": {
"auditCompletedOn": "05.12.2024",
"auditedBy": "Sujith Somraaj (individual security researcher)",
"auditorGitHandle": "sujithsomraaj",
"auditReportPath": "./audit/reports/2024.12.05_DeBridgeDlnFacet(v1.0.0).pdf",
"auditCommitHash": "d72cb05510acc5bb794bde05af550ba2ef85d06d"
"audit20241206": {
"auditCompletedOn": "06.12.2024",
"auditedBy": "Sujith Somraaj (individual security researcher)",
Expand Down Expand Up @@ -95,6 +101,11 @@
"audit20241206"
]
},
"DeBridgeDlnFacet": {
"1.0.0": [
"audit20241205"
]
},
"EmergencyPauseFacet": {
"1.0.0": [
"audit20240913"
Expand Down
Binary file not shown.
103 changes: 80 additions & 23 deletions config/dln.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,83 @@
{
"arbitrum": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
"networks": {
"arbitrum": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"avalanche": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"bsc": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"mainnet": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"polygon": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"linea": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"base": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"optimism": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"gnosis": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"metis": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"solana": {
"dlnSource": "src5qyZHqTqecJV4aY6Cb6zDZLMDzrDKKezs22MPHr4"
}
},
"avalanche": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"bsc": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"mainnet": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"polygon": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"linea": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"base": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
},
"optimism": {
"dlnSource": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66"
}
"mappings": [
{
"chainId": 42161,
"deBridgeChainId": 42161
},
{
"chainId": 43114,
"deBridgeChainId": 43114
},
{
"chainId": 56,
"deBridgeChainId": 56
},
{
"chainId": 1,
"deBridgeChainId": 1
},
{
"chainId": 137,
"deBridgeChainId": 137
},
{
"chainId": 59144,
"deBridgeChainId": 59144
},
{
"chainId": 8453,
"deBridgeChainId": 8453
},
{
"chainId": 10,
"deBridgeChainId": 10
},
{
"chainId": 100,
"deBridgeChainId": 100000002
},
{
"chainId": 1088,
"deBridgeChainId": 100000004
},
{
"chainId": 1151111081099710,
"deBridgeChainId": 7565164
}
]
}
2 changes: 1 addition & 1 deletion config/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@
"rpcUrl": "https://opbnb.drpc.org",
"verificationType": "etherscan",
"explorerUrl": "https://opbnb.bscscan.com/",
"explorerApiUrl": "",
"explorerApiUrl": "https://api-opbnb.bscscan.com/api",
"multicallAddress": "0xcA11bde05977b3631167028862bE2a173976CA11",
"safeApiUrl": "https://safe-transaction-opbnb-mainnet.bnbchain.org/api",
"safeAddress": "0xaAD94196680Edb94B421bb5B1E1A0B27db686C72",
Expand Down
8 changes: 4 additions & 4 deletions deployments/_deployments_log_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -21199,9 +21199,9 @@
"staging": {
"1.0.0": [
{
"ADDRESS": "0xE500dED7b9C9f1020870B7a6Db076Dbd892C0fea",
"ADDRESS": "0xE15C7585636e62b88bA47A40621287086E0c2E33",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-02-22 14:29:31",
"TIMESTAMP": "2024-10-14 15:56:11",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000ef4fb24ad0916217251f553c0596f8edc630eb66",
"SALT": "",
"VERIFIED": "true"
Expand All @@ -21213,9 +21213,9 @@
"staging": {
"1.0.0": [
{
"ADDRESS": "0xE500dED7b9C9f1020870B7a6Db076Dbd892C0fea",
"ADDRESS": "0xE15C7585636e62b88bA47A40621287086E0c2E33",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-02-22 15:43:42",
"TIMESTAMP": "2024-10-15 09:42:45",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000ef4fb24ad0916217251f553c0596f8edc630eb66",
"SALT": "",
"VERIFIED": "true"
Expand Down
3 changes: 2 additions & 1 deletion deployments/arbitrum.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"ServiceFeeCollector": "0x9cc3164f01ED3796Fdf7Da538484D634608D2203",
"WormholeFacet": "0x7260Fd3F8D0bEb06fF5935C6eadE9f406107c270",
"SymbiosisFacet": "0x21571D628B0bCBeb954D5933A604eCac35bAF2c7",
"DeBridgeDlnFacet": "0xE500dED7b9C9f1020870B7a6Db076Dbd892C0fea",
"DeBridgeDlnFacet": "0xE15C7585636e62b88bA47A40621287086E0c2E33",
"MayanFacet": "0xd596C903d78870786c5DB0E448ce7F87A65A0daD",
"StandardizedCallFacet": "0xA7ffe57ee70Ac4998e9E9fC6f17341173E081A8f",
"MayanFacet": "0xd596C903d78870786c5DB0E448ce7F87A65A0daD",
"GenericSwapFacetV3": "0xFf6Fa203573Baaaa4AE375EB7ac2819d539e16FF",
Expand Down
5 changes: 2 additions & 3 deletions deployments/polygon.diamond.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
"Version": "1.0.0"
},
"0xE15C7585636e62b88bA47A40621287086E0c2E33": {
"Name": "",
"Version": ""
"Name": "DeBridgeDlnFacet",
"Version": "1.0.0"
},
"0x74763722d92832d247cFa92825b06098cf72BAA2": {
"Name": "RelayFacet",
Expand All @@ -140,4 +140,3 @@
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70"
}
}
}
2 changes: 1 addition & 1 deletion deployments/polygon.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"ServiceFeeCollector": "0x9cc3164f01ED3796Fdf7Da538484D634608D2203",
"LiFuelFeeCollector": "0x94EA56D8049e93E0308B9c7d1418Baf6A7C68280",
"AcrossFacetPacked": "0x7A3770a9504924d99D38BBba4F0116B756393Eb3",
"DeBridgeDlnFacet": "0xE500dED7b9C9f1020870B7a6Db076Dbd892C0fea",
"DeBridgeDlnFacet": "0xE15C7585636e62b88bA47A40621287086E0c2E33",
"AmarokFacetPacked": "0x0aB252E7b5167Be2aC7841Bdaf1689E1a475ceE7",
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70",
"GasRebateDistributor": "0x3116B8F099D7eFA6e24f39F80146Aac423365EB9",
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- [CBridge Facet](./CBridgeFacet.md)
- [Celer Circle Bridge Facet](./CelerCircleBridgeFacet.md)
- [Circle Bridge Facet](./CircleBridgeFacet.md)
- [DeBridge Facet](./DeBridgeFacet.md)
- [DeBridge DLN Facet](/docs/DeBridgeDlnFacet.md)
- [DEX Manager Facet](./DexManagerFacet.md)
- [DiamondCut Facet](./DiamondCutFacet.md)
- [DiamondLoupe Facet](./DiamondLoupeFacet.md)
Expand All @@ -21,9 +21,7 @@
- [Hop Facet Packed](./HopFacetPacked.md)
- [Hyphen Facet](./HyphenFacet.md)
- [LIFuel Facet](./LIFuelFacet.md)
- [MakerTeleport Facet](./MakerTeleportFacet.md)
- [Mayan Facet](./MayanFacet.md)
- [Multichain Facet](./MultichainFacet.md)
- [OmniBridge Facet](./OmniBridgeFacet.md)
- [Optimism Bridge Facet](./OptimismBridgeFacet.md)
- [Periphery Registry Facet](./PeripheryRegistryFacet.md)
Expand All @@ -34,7 +32,6 @@
- [Standardized Call Facet](./StandardizedCallFacet.md)
- [Stargate Facet](./StargateFacet.md)
- [Stargate FacetV2](./StargateFacetV2.md)
- [Synapse Bridge Facet](./SynapseBridgeFacet.md)
- [ThorSwap Facet](./ThorSwapFacet.md)
- [Withdraw Facet](./WithdrawFacet.md)

Expand Down
9 changes: 5 additions & 4 deletions script/demoScripts/demoDLN.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import deployments from '../../deployments/mainnet.staging.json'
import deployments from '../../deployments/arbitrum.staging.json'
import {
DeBridgeDlnFacet__factory,
ILiFi,
Expand All @@ -24,7 +24,7 @@ const main = async () => {

// Bridge 5 ARB from Polygon to USDC on Optimism
const resp = await fetch(
'https://api.dln.trade/v1.0/dln/order/quote?srcChainId=42161&srcChainTokenIn=0x912CE59144191C1204E64559FE8253a0e49E6548&srcChainTokenInAmount=5000000000000000000&dstChainId=10&dstChainTokenOut=0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85&prependOperatingExpenses=false'
'https://api.dln.trade/v1.0/dln/order/quote?srcChainId=42161&srcChainTokenIn=0x912CE59144191C1204E64559FE8253a0e49E6548&srcChainTokenInAmount=95000000000000000000&dstChainId=100000002&dstChainTokenOut=0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d&prependOperatingExpenses=false'
)
const quote = await resp.json()

Expand All @@ -42,14 +42,15 @@ const main = async () => {
sendingAssetId: srcChainTokenIn.address,
receiver: address,
minAmount: srcChainTokenIn.amount,
destinationChainId: 10,
destinationChainId: 100,
hasSourceSwaps: false,
hasDestinationCall: false,
}

const dlnData: DeBridgeDlnFacet.DeBridgeDlnDataStruct = {
receivingAssetId: dstChainTokenOut.address,
receiver: ethers.utils.solidityPack(['address'], [address]),
orderAuthorityDst: ethers.utils.solidityPack(['address'], [address]),
minAmountOut: dstChainTokenOut.recommendedAmount,
}

Expand All @@ -65,7 +66,7 @@ const main = async () => {
value: quote.fixFee,
})
await tx.wait()
console.info('Bridged USDC')
console.info('Bridged ARB')
}

main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract DeployScript is DeployScriptBase {
string memory json = vm.readFile(path);

address dlnSource = json.readAddress(
string.concat(".", network, ".dlnSource")
string.concat(".networks.", network, ".dlnSource")
);

return abi.encode(dlnSource);
Expand Down
39 changes: 39 additions & 0 deletions script/deploy/facets/UpdateDeBridgeDlnFacet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import { UpdateScriptBase } from "./utils/UpdateScriptBase.sol";
import { stdJson } from "forge-std/StdJson.sol";
import { DeBridgeDlnFacet } from "lifi/Facets/DeBridgeDlnFacet.sol";

contract DeployScript is UpdateScriptBase {
using stdJson for string;

struct ChainIdConfig {
uint256 chainId;
uint256 deBridgeChainId;
}

function run()
public
returns (address[] memory facets, bytes memory cutData)
{
return update("DeBridgeDlnFacet");
}

function getCallData() internal override returns (bytes memory) {
path = string.concat(root, "/config/dln.json");
json = vm.readFile(path);
bytes memory rawChains = json.parseRaw(".mappings");
ChainIdConfig[] memory cidCfg = abi.decode(
rawChains,
(ChainIdConfig[])
);

bytes memory callData = abi.encodeWithSelector(
DeBridgeDlnFacet.initDeBridgeDln.selector,
cidCfg
);

return callData;
}
}
Loading

0 comments on commit 7c9f170

Please sign in to comment.