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

Debridge DLN Facet (Version 1.0.0) [DeBridgeDlnFacet v1.0.0] #827

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
07219e2
Move DeBridgeDLNFacet from archive
ezynda3 Oct 8, 2024
69a5bae
Move docs from archive and update README
ezynda3 Oct 8, 2024
a1038fa
Merge branch 'main' into debridge-dln
ezynda3 Oct 9, 2024
091cf24
Merge branch 'main' of github.com:lifinance/contracts into debridge-dln
ezynda3 Oct 9, 2024
6fc5c78
improve code coverage
ezynda3 Oct 9, 2024
72c23ca
improve code coverage
ezynda3 Oct 9, 2024
7167772
Merge branch 'debridge-dln' of github.com:lifinance/contracts into de…
ezynda3 Oct 9, 2024
11225de
Merge branch 'main' of github.com:lifinance/contracts into debridge-dln
ezynda3 Oct 10, 2024
975f85e
Fix opbnb
ezynda3 Oct 10, 2024
ac123a3
Update variable naming
ezynda3 Oct 10, 2024
b059e8e
Add mappings
ezynda3 Oct 14, 2024
e259742
Update demo
ezynda3 Oct 15, 2024
bf09c10
Merge branch 'main' of github.com:lifinance/contracts into debridge-dln
ezynda3 Nov 22, 2024
d72cb05
fix tests
ezynda3 Nov 22, 2024
995543f
Check for empty non EVM address
ezynda3 Nov 27, 2024
92d8772
Various fixes
ezynda3 Nov 27, 2024
9f76e21
Add referral code
ezynda3 Nov 29, 2024
8bcb392
explicitly set orderAuthorityDst
ezynda3 Nov 29, 2024
3f1d103
Fix referral code mismatch
ezynda3 Dec 2, 2024
536860b
Always check for empty receiver address
ezynda3 Dec 5, 2024
3e527df
Merge branch 'main' into debridge-dln
ezynda3 Dec 5, 2024
f561360
Remove unneeded parameter
ezynda3 Dec 5, 2024
87bd31f
Merge branch 'debridge-dln' of github.com:lifinance/contracts into de…
ezynda3 Dec 5, 2024
919d6ff
Merge branch 'main' into debridge-dln
ezynda3 Dec 12, 2024
5c6b7b3
Update audit log
ezynda3 Dec 12, 2024
ef13196
Merge branch 'main' into debridge-dln
ezynda3 Dec 13, 2024
be075af
sort audited contracts
ezynda3 Dec 13, 2024
4bd0d9c
Merge branch 'main' into debridge-dln
ezynda3 Dec 13, 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
13 changes: 0 additions & 13 deletions archive/scripts/Deploy/UpdateDeBridgeDlnFacet.s.sol

This file was deleted.

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 @@ -442,7 +442,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",
ezynda3 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -20723,9 +20723,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 @@ -20737,9 +20737,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",
ezynda3 marked this conversation as resolved.
Show resolved Hide resolved
"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"
}
},
"Periphery": {
Expand All @@ -136,4 +136,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.
6 changes: 1 addition & 5 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,19 +21,15 @@
- [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)
- [Polygon Bridge Facet](./PolygonBridgeFacet.md)
- [Ronin Bridge Facet](./RoninBridgeFacet.md)
- [Squid Facet](./SquidFacet.md)
- [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'
ezynda3 marked this conversation as resolved.
Show resolved Hide resolved
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")
ezynda3 marked this conversation as resolved.
Show resolved Hide resolved
);

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;
}
ezynda3 marked this conversation as resolved.
Show resolved Hide resolved
}
Loading