Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f621f30
fix: remove gas airdrop logic
ChiTimesChi Apr 17, 2025
3b7545d
feat: allow governance to withdraw unspent gas airdops
ChiTimesChi Apr 17, 2025
2cde3ea
feat: add legacy flag
ChiTimesChi Apr 17, 2025
20b104d
test: coverage for legacy flagf
ChiTimesChi Apr 17, 2025
285d915
test: coverage for new gov actions
ChiTimesChi Apr 17, 2025
f778571
test: reenabling
ChiTimesChi Apr 17, 2025
e9bb701
chore: revert docs formatting changes
ChiTimesChi Apr 22, 2025
189b72e
chore: bump bridge version
ChiTimesChi Apr 23, 2025
acbcaa8
refactor: more explicit name for sending tokens
ChiTimesChi Apr 23, 2025
0f34b97
chore: update actions/cache@v2 to v4 in GitHub workflows
ChiTimesChi Apr 23, 2025
3407298
fix: update tests
ChiTimesChi Apr 23, 2025
84491d9
test: expected behaviour for mint/withdraw pre/post legacy workflows
ChiTimesChi May 30, 2025
2d66d69
feat: fallbacks to regular mint/withdraw
ChiTimesChi May 30, 2025
c314e1d
test: reentrancy cases
ChiTimesChi May 30, 2025
f9cda06
test: node group caller only
ChiTimesChi May 30, 2025
880b817
test: withdrawFees cases
ChiTimesChi May 30, 2025
82828e5
fix: reset fees before transfer
ChiTimesChi May 30, 2025
85d9566
fix: old repo tests (#338)
ChiTimesChi Jun 4, 2025
bd94918
Merge branch 'feat/syn-bridge-unified' into syn-100-legacy-workflows
ChiTimesChi Jun 4, 2025
f63c26d
refactor: better separation of security checks
ChiTimesChi Jun 4, 2025
ec6948b
Merge pull request #335 from synapsecns/syn-100-legacy-workflows
ChiTimesChi Jun 5, 2025
4616c2f
Merge branch 'feat/syn-bridge-unified' into syn-102-withdraw-fees
ChiTimesChi Jun 5, 2025
2b5e00a
Merge pull request #336 from synapsecns/syn-102-withdraw-fees
ChiTimesChi Jun 5, 2025
c35907c
SYN-106: minor suggestions (#337)
ChiTimesChi Jun 6, 2025
18b7fe9
Merge branch 'master' into feat/syn-bridge-unified
ChiTimesChi Jun 18, 2025
b7fb369
SYN-94: disable initializer in SynapseBridge implementation (#342)
ChiTimesChi Jun 27, 2025
a67c932
SYN-94: deploy script (#343)
ChiTimesChi Jun 29, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
node-version: "${{ steps.nvm.outputs.NVMRC }}"

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
submodules: recursive

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
submodules: recursive

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
38 changes: 24 additions & 14 deletions contracts/bridge/SynapseBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
mapping(address => uint256) private fees;

uint256 public startBlockNumber;
uint256 public constant bridgeVersion = 6;
uint256 public constant bridgeVersion = 8;
uint256 public chainGasAmount;
address payable public WETH_ADDRESS;

mapping(bytes32 => bool) private kappaMap;
bool public isLegacySendDisabled;

modifier legacySendEnabled() {
require(!isLegacySendDisabled, "Legacy send is disabled");
_;
}

receive() external payable {}

Expand All @@ -48,6 +54,17 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
chainGasAmount = amount;
}

function withdrawChainGas() external {
require(hasRole(GOVERNANCE_ROLE, msg.sender), "Not governance");
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "ETH_TRANSFER_FAILED");
}

function setLegacySendDisabled(bool _isLegacySendDisabled) external {
require(hasRole(GOVERNANCE_ROLE, msg.sender), "Not governance");
isLegacySendDisabled = _isLegacySendDisabled;
}

function setWethAddress(address payable _wethAddress) external {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not admin");
WETH_ADDRESS = _wethAddress;
Expand Down Expand Up @@ -167,7 +184,7 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
uint256 chainId,
IERC20 token,
uint256 amount
) external nonReentrant whenNotPaused {
) external nonReentrant whenNotPaused legacySendEnabled {
emit TokenDeposit(to, chainId, token, amount);
token.safeTransferFrom(msg.sender, address(this), amount);
}
Expand All @@ -184,7 +201,7 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant whenNotPaused {
) external nonReentrant whenNotPaused legacySendEnabled {
emit TokenRedeem(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
Expand Down Expand Up @@ -244,9 +261,6 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
emit TokenMint(to, token, amount.sub(fee), fee, kappa);
token.mint(address(this), amount);
IERC20(token).safeTransfer(to, amount.sub(fee));
if (chainGasAmount != 0 && address(this).balance > chainGasAmount) {
to.call.value(chainGasAmount)("");
}
}

/**
Expand All @@ -269,7 +283,7 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant whenNotPaused {
) external nonReentrant whenNotPaused legacySendEnabled {
emit TokenDepositAndSwap(to, chainId, token, amount, tokenIndexFrom, tokenIndexTo, minDy, deadline);
token.safeTransferFrom(msg.sender, address(this), amount);
}
Expand All @@ -294,7 +308,7 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
uint8 tokenIndexTo,
uint256 minDy,
uint256 deadline
) external nonReentrant whenNotPaused {
) external nonReentrant whenNotPaused legacySendEnabled {
emit TokenRedeemAndSwap(to, chainId, token, amount, tokenIndexFrom, tokenIndexTo, minDy, deadline);
token.burnFrom(msg.sender, amount);
}
Expand All @@ -317,7 +331,7 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
uint8 swapTokenIndex,
uint256 swapMinAmount,
uint256 swapDeadline
) external nonReentrant whenNotPaused {
) external nonReentrant whenNotPaused legacySendEnabled {
emit TokenRedeemAndRemove(to, chainId, token, amount, swapTokenIndex, swapMinAmount, swapDeadline);
token.burnFrom(msg.sender, amount);
}
Expand Down Expand Up @@ -353,10 +367,6 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
require(!kappaMap[kappa], "Kappa is already present");
kappaMap[kappa] = true;
fees[address(token)] = fees[address(token)].add(fee);
// Transfer gas airdrop
if (chainGasAmount != 0 && address(this).balance > chainGasAmount) {
to.call.value(chainGasAmount)("");
}
// first check to make sure more will be given than min amount required
uint256 expectedOutput = ISwap(pool).calculateSwap(tokenIndexFrom, tokenIndexTo, amount.sub(fee));

Expand Down Expand Up @@ -526,7 +536,7 @@ contract SynapseBridge is Initializable, AccessControlUpgradeable, ReentrancyGua
uint256 chainId,
ERC20Burnable token,
uint256 amount
) external nonReentrant whenNotPaused {
) external nonReentrant whenNotPaused legacySendEnabled {
emit TokenRedeemV2(to, chainId, token, amount);
token.burnFrom(msg.sender, amount);
}
Expand Down
Loading
Loading