Skip to content

Commit

Permalink
Merge branch 'master' into fix/FbV2-setDeployBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Dec 10, 2024
2 parents c65b451 + 3d3530d commit a3f394f
Show file tree
Hide file tree
Showing 44 changed files with 733 additions and 90 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
# ignore ifacemaker files
*_generated.go linguist-generated
contrib/opbot/generated/* linguist-generated
*.contractinfo.json linguist-generated=true
*.contractinfo.json linguist-generated


# svg should be treated as a binary https://git.io/JE2VK
*.svg binary
*.sol linguist-language=Solidity

.vscode/*.json linguist-language=jsonc

# foundry deploy data
packages/**/deployments/*.json linguist-generated
16 changes: 16 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.5.13](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-12-08)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.5.12](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-12-06)

**Note:** Version bump only for package @synapsecns/bridge-docs





## [0.5.11](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-12-02)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
24 changes: 24 additions & 0 deletions docs/bridge/docs/01-About/04-SYN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: $SYN Token
---

# $SYN Token

$SYN is the governance token for the Synapse Protocol. There are no unlocks, all future $SYN emissions are goverened by the [DAO](/docs/About/DAO).

Liquidity for the [$SYN](https://coinmarketcap.com/currencies/synapse-2/) token can be found here:

| Venue | Link |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Coinbase | `https://www.coinbase.com/price/synapse` [](https://www.coinbase.com/price/synapse) |
| Sushi | `https://www.sushi.com/ethereum/pool/v2/0x4a86c01d67965f8cb3d0aaa2c655705e64097c31` [](https://www.sushi.com/ethereum/pool/v2/0x4a86c01d67965f8cb3d0aaa2c655705e64097c31) |
| Revolut | `https://www.revolut.com/crypto/price/syn` [](https://www.revolut.com/crypto/price/syn) |
| Binance (Spot) | `https://www.binance.com/en/trade/SYN_USDT?type=spot` [](https://www.binance.com/en/trade/SYN_USDT?type=spot) |
| Binance (Perpetuals) | `https://www.binance.com/en/futures/SYNUSDT` [](https://www.binance.com/en/futures/SYNUSDT) |
| Bybit (SYN/USDT) | `https://www.bybit.com/trade/usdt/SYNUSDT` [](https://www.bybit.com/trade/usdt/SYNUSDT) |
| HTX | `https://www.htx.com/price/syn/` [](https://www.htx.com/price/syn/) |
| Kraken | `https://www.kraken.com/prices/synapse` [](https://www.kraken.com/prices/synapse) |
| KuCoin | `https://www.kucoin.com/price/SYN` [](https://www.kucoin.com/price/SYN) |
<br />

All $SYN token addresses can be found [here](/docs/Contracts/SYN).
32 changes: 32 additions & 0 deletions docs/bridge/docs/05-Contracts/09-SYN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: $SYN Token
---

:::note This list may be incomplete

The canonical list is hosted within the SynapseCNS on [Github](https://github.com/synapsecns/synapse-contracts).

:::

# $SYN

| Chain | Address |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Arbitrum | `0x080f6aed32fc474dd5717105dba5ea57268f46eb` [](https://arbiscan.io/address/0x080f6aed32fc474dd5717105dba5ea57268f46eb) |
| Aurora | `0xd80d8688b02B3FD3afb81cDb124F188BB5aD0445` [](https://explorer.mainnet.aurora.dev/address/0xd80d8688b02B3FD3afb81cDb124F188BB5aD0445) |
| Avalanche | `0x1f1E7c893855525b303f99bDF5c3c05Be09ca251` [](https://snowscan.xyz/address/0x1f1E7c893855525b303f99bDF5c3c05Be09ca251) |
| Base | `0x432036208d2717394d2614d6697c46DF3Ed69540` [](https://basescan.org/address/0x432036208d2717394d2614d6697c46DF3Ed69540) |
| Blast | `0x9592f08387134e218327E6E8423400eb845EdE0E` [](https://blastscan.io/address/0x9592f08387134e218327E6E8423400eb845EdE0E) |
| Boba | `0xb554A55358fF0382Fb21F0a478C3546d1106Be8c` [](https://blockexplorer.boba.network/address/0xb554A55358fF0382Fb21F0a478C3546d1106Be8c) |
| BSC | `0xa4080f1778e69467e905b8d6f72f6e441f9e9484` [](https://bscscan.com/address/0xa4080f1778e69467e905b8d6f72f6e441f9e9484) |
| Canto | `0x555982d2E211745b96736665e19D9308B615F78e` [](https://canto.dex.guru/address/0x555982d2E211745b96736665e19D9308B615F78e) |
| Cronos | `0xFD0F80899983b8D46152aa1717D76cba71a31616` [](https://cronos.org/explorer/address/0xFD0F80899983b8D46152aa1717D76cba71a31616) |
| DFK Chain | `0xB6b5C854a8f71939556d4f3a2e5829F7FcC1bf2A` [](https://dfkchain.com/address/0xB6b5C854a8f71939556d4f3a2e5829F7FcC1bf2A) |
| Ethereum | `0x0f2D719407FdBeFF09D87557AbB7232601FD9F29` [](https://etherscan.io/address/0x0f2D719407FdBeFF09D87557AbB7232601FD9F29) |
| Fantom | `0xE55e19Fb4F2D85af758950957714292DAC1e25B2` [](https://ftmscan.com/address/0xE55e19Fb4F2D85af758950957714292DAC1e25B2) |
| Harmony | `0xE55e19Fb4F2D85af758950957714292DAC1e25B2` [](https://explorer.harmony.one/address/0xE55e19Fb4F2D85af758950957714292DAC1e25B2) |
| Metis | `0x67c10c397dd0ba417329543c1a40eb48aaa7cd00` [](https://andromeda-explorer.metis.io/address/0x67c10c397dd0ba417329543c1a40eb48aaa7cd00) |
| Moonbeam | `0xF44938b0125A6662f9536281aD2CD6c499F22004` [](https://moonbeam.moonscan.io/address/0xF44938b0125A6662f9536281aD2CD6c499F22004) |
| Moonriver | `0xd80d8688b02B3FD3afb81cDb124F188BB5aD0445` [](https://moonriver.moonscan.io/address/0xd80d8688b02B3FD3afb81cDb124F188BB5aD0445) |
| Optimism | `0x5A5fFf6F753d7C11A56A52FE47a177a87e431655` [](https://optimistic.etherscan.io/address/0x5A5fFf6F753d7C11A56A52FE47a177a87e431655) |
| Polygon | `0xf8f9efc0db77d8881500bb06ff5d6abc3070e695` [](https://polygonscan.com/address/0xf8f9efc0db77d8881500bb06ff5d6abc3070e695) |
2 changes: 1 addition & 1 deletion docs/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/bridge-docs",
"version": "0.5.11",
"version": "0.5.13",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-rfq/.solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ contracts/interfaces/IFastBridge.sol
contracts/legacy/**/*.sol
script/FastBridge.s.sol
test/FastBridge.t.sol
test/FastBridgeMock.sol
test/mocks/FastBridgeMock.sol
8 changes: 8 additions & 0 deletions packages/contracts-rfq/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.14.7](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-12-05)

**Note:** Version bump only for package @synapsecns/contracts-rfq





## [0.14.6](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-11-28)


Expand Down
130 changes: 126 additions & 4 deletions packages/contracts-rfq/contracts/AdminV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
using SafeERC20 for IERC20;

/// @notice Struct for storing information about a prover.
/// @param id The ID of the prover: its position in `_allProvers` plus one,
/// or zero if the prover has never been added.
/// @param activeFromTimestamp The timestamp at which the prover becomes active,
/// or zero if the prover has never been added or is no longer active.
struct ProverInfo {
uint16 id;
uint240 activeFromTimestamp;
}

/// @notice The address reserved for the native gas token (ETH on Ethereum and most L2s, AVAX on Avalanche, etc.).
address public constant NATIVE_GAS_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

/// @notice The role identifier for the Quoter API's off-chain authentication.
/// @dev Only addresses with this role can post FastBridge quotes to the API.
bytes32 public constant QUOTER_ROLE = keccak256("QUOTER_ROLE");

/// @notice The role identifier for the Prover's on-chain authentication in FastBridge.
/// @dev Only addresses with this role can provide proofs that a FastBridge request has been relayed.
bytes32 public constant PROVER_ROLE = keccak256("PROVER_ROLE");

/// @notice The role identifier for the Guard's on-chain authentication in FastBridge.
/// @dev Only addresses with this role can dispute submitted relay proofs during the dispute period.
bytes32 public constant GUARD_ROLE = keccak256("GUARD_ROLE");
Expand All @@ -51,6 +57,11 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
/// @notice The default cancel delay set during contract deployment.
uint256 public constant DEFAULT_CANCEL_DELAY = 1 days;

/// @notice The minimum dispute penalty time that can be set by the governor.
uint256 public constant MIN_DISPUTE_PENALTY_TIME = 1 minutes;
/// @notice The default dispute penalty time set during contract deployment.
uint256 public constant DEFAULT_DISPUTE_PENALTY_TIME = 30 minutes;

/// @notice The protocol fee rate taken on the origin amount deposited in the origin chain.
uint256 public protocolFeeRate;

Expand All @@ -66,6 +77,14 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
/// This is exposed for conveniece for off-chain indexers that need to know the deployment block.
uint256 public deployBlock;

/// @notice The timeout period that is used to temporarily disactivate a disputed prover.
uint256 public disputePenaltyTime;

/// @notice A list of all provers ever added to the contract. Can hold up to 2^16-1 provers.
address[] private _allProvers;
/// @notice A mapping of provers to their information: id and activeFromTimestamp.
mapping(address => ProverInfo) private _proverInfos;

/// @notice This variable is deprecated and should not be used.
/// @dev Use ZapNative V2 requests instead.
uint256 public immutable chainGasAmount = 0;
Expand All @@ -74,6 +93,35 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
_grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
_setCancelDelay(DEFAULT_CANCEL_DELAY);
_setDeployBlock(block.number);
_setDisputePenaltyTime(DEFAULT_DISPUTE_PENALTY_TIME);
}

/// @inheritdoc IAdminV2
function addProver(address prover) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (getActiveProverID(prover) != 0) revert ProverAlreadyActive();
ProverInfo storage $ = _proverInfos[prover];
// Add the prover to the list of all provers and record its id (its position + 1),
// if this has not already been done.
if ($.id == 0) {
_allProvers.push(prover);
uint256 id = _allProvers.length;
if (id > type(uint16).max) revert ProverCapacityExceeded();
// Note: this is a storage write.
$.id = uint16(id);
}
// Update the activeFrom timestamp.
// Note: this is a storage write.
$.activeFromTimestamp = uint240(block.timestamp);
emit ProverAdded(prover);
}

/// @inheritdoc IAdminV2
function removeProver(address prover) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (getActiveProverID(prover) == 0) revert ProverNotActive();
// We never remove provers from the list of all provers to preserve their IDs,
// so we just need to reset the activeFrom timestamp.
_proverInfos[prover].activeFromTimestamp = 0;
emit ProverRemoved(prover);
}

/// @inheritdoc IAdminV2
Expand All @@ -86,6 +134,11 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
_setDeployBlock(blockNumber);
}

/// @inheritdoc IAdminV2
function setDisputePenaltyTime(uint256 newDisputePenaltyTime) external onlyRole(GOVERNOR_ROLE) {
_setDisputePenaltyTime(newDisputePenaltyTime);
}

/// @inheritdoc IAdminV2
function setProtocolFeeRate(uint256 newFeeRate) external onlyRole(GOVERNOR_ROLE) {
if (newFeeRate > FEE_RATE_MAX) revert FeeRateAboveMax();
Expand All @@ -110,6 +163,66 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
}
}

/// @inheritdoc IAdminV2
function getProvers() external view returns (address[] memory provers) {
uint256 length = _allProvers.length;
// Calculate the number of active provers.
uint256 activeProversCount = 0;
for (uint256 i = 0; i < length; i++) {
if (getActiveProverID(_allProvers[i]) != 0) {
activeProversCount++;
}
}
// Do the second pass to populate the provers array.
provers = new address[](activeProversCount);
uint256 activeProversIndex = 0;
for (uint256 i = 0; i < length; i++) {
address prover = _allProvers[i];
if (getActiveProverID(prover) != 0) {
provers[activeProversIndex++] = prover;
}
}
}

/// @inheritdoc IAdminV2
function getProverInfo(address prover) external view returns (uint16 proverID, uint256 activeFromTimestamp) {
proverID = _proverInfos[prover].id;
activeFromTimestamp = _proverInfos[prover].activeFromTimestamp;
}

/// @inheritdoc IAdminV2
function getProverInfoByID(uint16 proverID) external view returns (address prover, uint256 activeFromTimestamp) {
if (proverID == 0 || proverID > _allProvers.length) return (address(0), 0);
prover = _allProvers[proverID - 1];
activeFromTimestamp = _proverInfos[prover].activeFromTimestamp;
}

/// @inheritdoc IAdminV2
function getActiveProverID(address prover) public view returns (uint16) {
// Aggregate the read operations from the same storage slot.
uint16 id = _proverInfos[prover].id;
uint256 activeFromTimestamp = _proverInfos[prover].activeFromTimestamp;
// Return zero if the prover has never been added or is no longer active.
if (activeFromTimestamp == 0 || activeFromTimestamp > block.timestamp) return 0;
return id;
}

/// @notice Internal logic to apply the dispute penalty time to a given prover. Will make the prover inactive
/// for `disputePenaltyTime` seconds. No-op if the prover ID does not exist or prover is already inactive.
function _applyDisputePenaltyTime(uint16 proverID) internal {
// Check that the prover exists.
if (proverID == 0 || proverID > _allProvers.length) return;
address prover = _allProvers[proverID - 1];
ProverInfo storage $ = _proverInfos[prover];
// No-op if the prover is already inactive.
if ($.activeFromTimestamp == 0) return;
uint256 newActiveFromTimestamp = block.timestamp + disputePenaltyTime;
// Update the activeFrom timestamp.
// Note: this is a storage write.
$.activeFromTimestamp = uint240(newActiveFromTimestamp);
emit DisputePenaltyTimeApplied(prover, newActiveFromTimestamp);
}

/// @notice Internal logic to set the cancel delay. Security checks are performed outside of this function.
/// @dev This function is marked as private to prevent child contracts from calling it directly.
function _setCancelDelay(uint256 newCancelDelay) private {
Expand All @@ -125,4 +238,13 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
deployBlock = blockNumber;
emit DeployBlockSet(blockNumber);
}

/// @notice Internal logic to set the dispute penalty time. Security checks are performed outside of this function.
/// @dev This function is marked as private to prevent child contracts from calling it directly.
function _setDisputePenaltyTime(uint256 newDisputePenaltyTime) private {
if (newDisputePenaltyTime < MIN_DISPUTE_PENALTY_TIME) revert DisputePenaltyTimeBelowMin();
uint256 oldDisputePenaltyTime = disputePenaltyTime;
disputePenaltyTime = newDisputePenaltyTime;
emit DisputePenaltyTimeUpdated(oldDisputePenaltyTime, newDisputePenaltyTime);
}
}
Loading

0 comments on commit a3f394f

Please sign in to comment.