Skip to content

Commit

Permalink
Merge branch 'master' into xiaoch05-eth2arbi
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Aug 7, 2023
2 parents c28cdc7 + da21651 commit e7a46e3
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 424 deletions.
13 changes: 13 additions & 0 deletions helix-contract/address/arbi2eth-ln-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,18 @@
"LnBridgeLogic": "0x1928C29b8eCD6c877A2E6bEF01bD50C72E1be0cC",
"LnBridgeProxy": "0xFBAD806Bdf9cEC2943be281FB355Da05068DE925",
"Ring": "0x9e523234D36973f9e38642886197D023C88e307e"
},
"arbitrum2ethereumLnV2-ethereum": {
"LnBridgeProxyAdmin": "0x66D86a686e50C98BaC236105eFAFb99Ee7605dc5",
"LnBridgeLogic": "0xd12917F42E09e216623010EB5f15c39d4978d322",
"LnBridgeProxy": "0xeAb1F01a8f4A2687023B159c2063639Adad5304E",
"Ring": "0x9469D013805bFfB7D3DEBe5E7839237e535ec483",
"Inbox": "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f"
},
"arbitrum2ethereumLnV2-arbitrum": {
"LnBridgeProxyAdmin": "0x61B6B8c7C00aA7F060a2BEDeE6b11927CC9c3eF1",
"LnBridgeLogic": "0x2FC7Def96561ca5e1f0Aa333cb78cFA51DeE3218",
"LnBridgeProxy": "0xD1B10B114f1975d8BCc6cb6FC43519160e2AA978",
"Ring": "0x9e523234D36973f9e38642886197D023C88e307e"
}
}
13 changes: 13 additions & 0 deletions helix-contract/contracts/ln/base/LnOppositeBridgeSource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract LnOppositeBridgeSource is LnBridgeHelper {
}
struct LnProviderInfo {
LnProviderConfigure config;
bool pause;
bytes32 lastTransferId;
}

Expand Down Expand Up @@ -100,6 +101,16 @@ contract LnOppositeBridgeSource is LnBridgeHelper {
tokenInfos[_token].penaltyLnCollateral = _penaltyLnCollateral;
}

function providerPause(address sourceToken) external {
bytes32 providerKey = getProviderKey(msg.sender, sourceToken);
lnProviders[providerKey].pause = true;
}

function providerUnpause(address sourceToken) external {
bytes32 providerKey = getProviderKey(msg.sender, sourceToken);
lnProviders[providerKey].pause = false;
}

// lnProvider can register or update its configure by using this function
// * `margin` is the increased value of the deposited margin
function updateProviderFeeAndMargin(
Expand Down Expand Up @@ -179,6 +190,8 @@ contract LnOppositeBridgeSource is LnBridgeHelper {
bytes32 providerKey = getProviderKey(snapshot.provider, snapshot.sourceToken);
LnProviderInfo memory providerInfo = lnProviders[providerKey];

require(!providerInfo.pause, "provider paused");

TokenInfo memory tokenInfo = tokenInfos[snapshot.sourceToken];

uint256 providerFee = calculateProviderFee(providerInfo.config, amount);
Expand Down
30 changes: 27 additions & 3 deletions helix-contract/deploy/deploy_arbi2eth_ln.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ const daoOnEthereum = "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4";

const initTransferId = "0x0000000000000000000000000000000000000000000000000000000000000000";

async function getLnBridgeTargetInitData(wallet, dao, inbox) {
const bridgeContract = await ethers.getContractFactory("Arb2EthTarget", wallet);
const initdata = await ProxyDeployer.getInitializerData(
bridgeContract.interface,
[dao, inbox],
"initialize",
);
console.log("LnBridgeInitData init data:", initdata);
}

async function getLnBridgeSourceInitData(wallet, dao) {
const bridgeContract = await ethers.getContractFactory("Arb2EthSource", wallet);
const initdata = await ProxyDeployer.getInitializerData(
bridgeContract.interface,
[dao],
"initialize",
);
console.log("LnBridgeInitData init data:", initdata);
}

async function transferAndLockMargin(
wallet,
bridgeAddress,
Expand Down Expand Up @@ -294,11 +314,15 @@ async function main() {
const arbitrumWallet = wallets[0];
const ethereumWallet = wallets[1];


//await getLnBridgeTargetInitData(arbitrumWallet, "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4", "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f");
await getLnBridgeSourceInitData(arbitrumWallet, "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4");
return;

/*
const deployed = await deploy(arbitrumWallet, ethereumWallet);
console.log(deployed);
return;

*/


const arbitrumLnBridgeAddress = "0x7B8413FA1c1033844ac813A2E6475E15FB0fb3BA";
Expand Down Expand Up @@ -384,7 +408,7 @@ async function main() {
await requestWithdrawMargin(
ethereumWallet,
ethereumLnBridgeAddress,
"0xD1207442C3AC4BABC7500E06C2C08E3E5A46A452D92A7936A9B90ECE22C55E5E", //lastTransferId
"0xDD5703D47E4494FFC87660F3CBF2AFBA7A137755A91C81DC7ED120BB18E33A83", //lastTransferId
ringArbitrumAddress,
ethers.utils.parseEther("3"), // amount
);
Expand Down
15 changes: 14 additions & 1 deletion helix-contract/flatten/lnv2/Arb2EthSource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* '----------------' '----------------' '----------------' '----------------' '----------------' '
*
*
* 7/11/2023
* 7/12/2023
**/

pragma solidity ^0.8.10;
Expand Down Expand Up @@ -1284,6 +1284,7 @@ contract LnOppositeBridgeSource is LnBridgeHelper {
}
struct LnProviderInfo {
LnProviderConfigure config;
bool pause;
bytes32 lastTransferId;
}

Expand Down Expand Up @@ -1346,6 +1347,16 @@ contract LnOppositeBridgeSource is LnBridgeHelper {
tokenInfos[_token].penaltyLnCollateral = _penaltyLnCollateral;
}

function providerPause(address sourceToken) external {
bytes32 providerKey = getProviderKey(msg.sender, sourceToken);
lnProviders[providerKey].pause = true;
}

function providerUnpause(address sourceToken) external {
bytes32 providerKey = getProviderKey(msg.sender, sourceToken);
lnProviders[providerKey].pause = false;
}

// lnProvider can register or update its configure by using this function
// * `margin` is the increased value of the deposited margin
function updateProviderFeeAndMargin(
Expand Down Expand Up @@ -1425,6 +1436,8 @@ contract LnOppositeBridgeSource is LnBridgeHelper {
bytes32 providerKey = getProviderKey(snapshot.provider, snapshot.sourceToken);
LnProviderInfo memory providerInfo = lnProviders[providerKey];

require(!providerInfo.pause, "provider paused");

TokenInfo memory tokenInfo = tokenInfos[snapshot.sourceToken];

uint256 providerFee = calculateProviderFee(providerInfo.config, amount);
Expand Down
Loading

0 comments on commit e7a46e3

Please sign in to comment.