Skip to content

Commit

Permalink
Merge branch 'master' into feat/FbV2-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Nov 30, 2024
2 parents c68478b + ec5fd1f commit d560457
Show file tree
Hide file tree
Showing 99 changed files with 3,279 additions and 739 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
# ignore ifacemaker files
*_generated.go linguist-generated
contrib/opbot/generated/* linguist-generated
*.contractinfo.json linguist-generated=true


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

.vscode/*.json linguist-language=jsonc
5 changes: 5 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
with:
pattern: '.github/renovate.json' # Regular expression for filename to validate, default to *.json

- name: jsonc-syntax-check
uses: stevieb9/[email protected]
with:
pattern: .vscode/*.json'


- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
Expand Down
11 changes: 9 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
// This file (like all vscode metadata files) uses JSON with Comments (JSONC) format, which supports:
// - Comments (both single and multi-line)
// - Trailing commas
// - More lenient syntax than standard JSON

// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"juanblanco.solidity",
"golang.go",
"bierner.markdown-mermaid",
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
],
}
}
13 changes: 10 additions & 3 deletions contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
})
if err != nil {
log.Printf("error submitting refund: %v\n", err)
_, err := ctx.Response().Reply("error submitting refund")
if err != nil {
log.Println(err)
}
return
}

Expand All @@ -331,17 +335,19 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
if err != nil || !status.HasTx() {
b.logger.Errorf(ctx, "error fetching quote request: %v", err)
return fmt.Errorf("error fetching quote request: %w", err)
} else if !status.HasTx() {
return fmt.Errorf("no transaction hash found yet")
}
return nil
},
retry.WithMaxAttempts(5),
retry.WithMaxAttemptTime(30*time.Second),
retry.WithMaxTotalTime(1*time.Minute),
)

if err != nil {
b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err)
_, err := ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
if err != nil {
log.Println(err)
b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err)
}
return
}
Expand All @@ -351,6 +357,7 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
if err != nil {
log.Println(err)
}

},
}
}
Expand Down
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.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-11-19)

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





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

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





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

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
12 changes: 11 additions & 1 deletion docs/bridge/docs/02-Bridge/02-REST-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ title: REST API

# REST API

Get read-only data from on-chain Synapse contracts, and generate Bridge and Swap quotes, plus additional transaction information.
The Synapse REST API is a read-only API that allows you to integrate the Synapse liquidity network into your application.

Through HTTP requests, developers can integrate Synapse cross-chain tokens and liquidity transfers dynamically into their applications. Developers can retrieve quotes, as well as generate the relevant call data for Synapse Bridges and Swaps. Example requests can be found below in the [API-docs](#api-docs) section.


The Synapse REST API is built on top of the [Synapse Bridge SDK](https://docs.synapseprotocol.com/docs/Bridge/SDK).


The API is available at [`https://api.synapseprotocol.com/`](https://api.synapseprotocol.com/).


## API-docs

Expand All @@ -17,6 +26,7 @@ Get read-only data from on-chain Synapse contracts, and generate Bridge and Swap
| Date | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 2024‑10‑01 | [https://synapse-rest-api-v2.herokuapp.com/](https://synapse-rest-api-v2.herokuapp.com/) is no longer maintained and has been fully deprecated as of October 2024. |
| 2024‑11‑19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) the /bridgeTxInfo endpoint has been consolidated into the /bridge endpoint, which now returns call data |

## Support

Expand Down
2 changes: 1 addition & 1 deletion docs/bridge/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const config: Config = {
favicon: 'brand-assets/synapse-mark.svg',

// Set the production url of your site here
url: 'https://docs.bridge.synapseprotocol.com',
url: 'https://docs.synapseprotocol.com',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
Expand Down
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.3",
"version": "0.5.5",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
73 changes: 73 additions & 0 deletions packages/contracts-rfq/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,79 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

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


### Bug Fixes

* **contracts-rfq:** `TokenZapV1` native gas token behaviour [SLT-389] ([#3418](https://github.com/synapsecns/sanguine/issues/3418)) ([ee3705a](https://github.com/synapsecns/sanguine/commit/ee3705a1fabf52746a933964d6d52ba1ca2379d6))





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

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





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

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





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

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





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

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





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

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





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


### Features

* **contracts-rfq:** Token Zap [SLT-389] ([#3352](https://github.com/synapsecns/sanguine/issues/3352)) ([743e859](https://github.com/synapsecns/sanguine/commit/743e859e3274ed449c6410441bd664ff2aaf9740)), closes [#3382](https://github.com/synapsecns/sanguine/issues/3382)





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


### Features

* **contracts-rfq:** rework permisionless cancellation [SLT-489] ([#3382](https://github.com/synapsecns/sanguine/issues/3382)) ([7932f41](https://github.com/synapsecns/sanguine/commit/7932f416341a227db295c33f232efde89fd2c50c))





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

**Note:** Version bump only for package @synapsecns/contracts-rfq
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-rfq/contracts/Admin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity ^0.8.20;

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";

import {UniversalTokenLib} from "./libs/UniversalToken.sol";
import {IAdmin} from "./interfaces/IAdmin.sol";
import {UniversalTokenLib} from "./libs/UniversalToken.sol";

contract Admin is IAdmin, AccessControlEnumerable {
using UniversalTokenLib for address;
Expand Down
109 changes: 109 additions & 0 deletions packages/contracts-rfq/contracts/AdminV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

// ════════════════════════════════════════════════ INTERFACES ═════════════════════════════════════════════════════

import {IAdminV2} from "./interfaces/IAdminV2.sol";
import {IAdminV2Errors} from "./interfaces/IAdminV2Errors.sol";

// ═════════════════════════════════════════════ EXTERNAL IMPORTS ══════════════════════════════════════════════════

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";
import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

/// @title AdminV2
/// @notice Provides administrative functions and controls for managing the FastBridgeV2 contract,
/// including access control and configuration settings.
contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
using SafeERC20 for IERC20;

/// @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");

/// @notice The role identifier for the Canceler's on-chain authentication in FastBridge.
/// @dev Only addresses with this role can cancel a FastBridge transaction without the cancel delay.
bytes32 public constant CANCELER_ROLE = keccak256("CANCELER_ROLE");

/// @notice The role identifier for the Governor's on-chain administrative authority.
/// @dev Only addresses with this role can perform administrative tasks within the contract.
bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

/// @notice The denominator for fee rates, representing 100%.
uint256 public constant FEE_BPS = 1e6;
/// @notice The maximum protocol fee rate: 1% of the origin amount.
uint256 public constant FEE_RATE_MAX = 0.01e6;

/// @notice The minimum cancel delay that can be set by the governor.
uint256 public constant MIN_CANCEL_DELAY = 1 hours;
/// @notice The default cancel delay set during contract deployment.
uint256 public constant DEFAULT_CANCEL_DELAY = 1 days;

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

/// @notice The accumulated protocol fee amounts.
mapping(address => uint256) public protocolFees;

/// @notice The delay period after which a transaction can be permissionlessly cancelled.
uint256 public cancelDelay;

/// @notice This variable is deprecated and should not be used.
/// @dev Use ZapNative V2 requests instead.
uint256 public immutable chainGasAmount = 0;

constructor(address defaultAdmin) {
_grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
_setCancelDelay(DEFAULT_CANCEL_DELAY);
}

/// @inheritdoc IAdminV2
function setCancelDelay(uint256 newCancelDelay) external onlyRole(GOVERNOR_ROLE) {
_setCancelDelay(newCancelDelay);
}

/// @inheritdoc IAdminV2
function setProtocolFeeRate(uint256 newFeeRate) external onlyRole(GOVERNOR_ROLE) {
if (newFeeRate > FEE_RATE_MAX) revert FeeRateAboveMax();
uint256 oldFeeRate = protocolFeeRate;
protocolFeeRate = newFeeRate;
emit FeeRateUpdated(oldFeeRate, newFeeRate);
}

/// @inheritdoc IAdminV2
function sweepProtocolFees(address token, address recipient) external onlyRole(GOVERNOR_ROLE) {
// Early exit if no accumulated fees.
uint256 feeAmount = protocolFees[token];
if (feeAmount == 0) return;
// Reset the accumulated fees first.
protocolFees[token] = 0;
emit FeesSwept(token, recipient, feeAmount);
// Sweep the fees as the last transaction action.
if (token == NATIVE_GAS_TOKEN) {
Address.sendValue(payable(recipient), feeAmount);
} else {
IERC20(token).safeTransfer(recipient, feeAmount);
}
}

/// @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 {
if (newCancelDelay < MIN_CANCEL_DELAY) revert CancelDelayBelowMin();
uint256 oldCancelDelay = cancelDelay;
cancelDelay = newCancelDelay;
emit CancelDelayUpdated(oldCancelDelay, newCancelDelay);
}
}
2 changes: 1 addition & 1 deletion packages/contracts-rfq/contracts/FastBridge.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "./libs/Errors.sol";
import {UniversalTokenLib} from "./libs/UniversalToken.sol";
Expand Down
Loading

0 comments on commit d560457

Please sign in to comment.