Skip to content

Commit

Permalink
Merge branch 'master' into widget/chain-update
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Oct 18, 2024
2 parents 7888c57 + 7f44c5d commit 0b9d43b
Show file tree
Hide file tree
Showing 125 changed files with 6,699 additions and 678 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'packages/contracts-rfq/**'
- '.github/workflows/solidity.yml'
- 'packages/solidity-devops/**'
branches:
# Solidity workflows are irrelevant for the FE release branch
- '!fe-release'
push:
paths:
- 'packages/contracts-core/**'
Expand Down Expand Up @@ -174,6 +177,7 @@ jobs:
with:
node-version: '${{steps.nvmrc.outputs.NVMRC}}'
target: './packages/${{matrix.package}}'
slither-config: './packages/${{matrix.package}}/slither.config.json'
ignore-compile: true
sarif: results.sarif
solc-version: 0.8.17
Expand Down Expand Up @@ -204,6 +208,9 @@ jobs:
- name: Installing dependencies
run: yarn install --immutable

- name: Install lcov
run: sudo apt-get update && sudo apt-get install -y lcov

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -222,6 +229,12 @@ jobs:
env:
FOUNDRY_FUZZ_RUNS: 10

# Some of the packages may want to exclude certain files from the coverage report (legacy code, scripts, tests)
- name: Apply filters to coverage report
if: ${{ matrix.package != 'solidity-devops' }}
working-directory: './packages/${{matrix.package}}'
run: npm run coverage:filter --if-present

- name: Send Coverage (Codecov)
if: ${{ matrix.package != 'solidity-devops' }}
uses: Wandalen/wretry.action@v1.0.36
Expand Down Expand Up @@ -267,7 +280,9 @@ jobs:
- name: Run tests and generate gas report
working-directory: './packages/${{matrix.package}}'
# Run separate set of tests (no fuzzing) to get accurate average gas cost estimates
run: forge test --mc GasBenchmark --gas-report > "../../gas-report-${{ matrix.package }}.ansi"
# Note: we use `npm run` with `--if-present` flag, allows not to define a gas:bench script in every package
# This is not natively supported by yarn yet, see: https://github.com/yarnpkg/yarn/pull/7159
run: npm run gas:bench --if-present > "../../gas-report-${{ matrix.package }}.ansi"

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.18
Expand Down
27 changes: 27 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.4.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.4.3...@synapsecns/bridge-docs@0.4.4) (2024-10-15)

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





## [0.4.3](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.4.2...@synapsecns/bridge-docs@0.4.3) (2024-10-15)

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





## [0.4.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.4.1...@synapsecns/bridge-docs@0.4.2) (2024-10-12)


### Bug Fixes

* **docs:** Fixes gh link ([#3280](https://github.com/synapsecns/sanguine/issues/3280)) ([f1dfc82](https://github.com/synapsecns/sanguine/commit/f1dfc82bc26d60262a92feda671d44a6d54a3ce1))





## [0.4.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.4.0...@synapsecns/bridge-docs@0.4.1) (2024-10-12)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
112 changes: 57 additions & 55 deletions docs/bridge/docs/02-Bridge/01-SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ The Synapse Bridge SDK is built on top of the [Synapse Router](/docs/Routers/Syn

### Use cases

* Integrate your front-end application with the Synapse Bridge.
* Provide bridge liquidity.
* Perform cross-chain arbitrage.
* Integrate the Synapse Javascript SDK with your non-Javascript application.
- Integrate your front-end application with the Synapse Bridge.
- Provide bridge liquidity.
- Perform cross-chain arbitrage.
- Integrate the Synapse Javascript SDK with your non-Javascript application.

## Install

:::note requires Node v16+

The SDK has only been fully tested on Node 16+ or greater. Earlier versions are not guaranteed to work.
The SDK has only been fully tested on Node 16+ or greater. Earlier versions are not guaranteed to work.

:::

Requires either the `npx` or `yarn` package manager.
Requires either the `npm` or `yarn` package manager.

| Options
|-
| `npx install @synapsecns/sdk-router`
| `yarn install @synapsecns/sdk-router`
| `npm install @synapsecns/sdk-router`
| `yarn add @synapsecns/sdk-router`

## Configure Ethers

Expand Down Expand Up @@ -60,8 +60,9 @@ const Synapse = new SynapseSDK(chainIds, providers)
:::tip Ethers v6

Use of Ethers v6 requires the `@ethersproject/providers` dependency to be installed via `npm` or `yarn`:
* `npm install @ethersproject/providers@^5.7.2`
* `yarn add @ethersproject/providers@^5.7.2`

- `npm install @ethersproject/providers@^5.7.2`
- `yarn add @ethersproject/providers@^5.7.2`

:::

Expand Down Expand Up @@ -90,11 +91,11 @@ const Synapse = new SynapseSDK(chainIds, providers)

`originQuery` and `destQuery`, returned by `bridgeQuote()` and required for `bridge()`, are [`Query`](https://synapserouter.gitbook.io/untitled/) objects, which contain:

* `swapAdapter`: (string): 0x address of the swap adapter.
* `tokenOut`: (string): 0x address of the outputted token on that chain.
* `minAmountOut`: (Ethers BigNumber): The min amount of value exiting the transaction.
* `deadline`: (Ethers BigNumber): The deadline for the potential transaction.
* `rawParams`: (string): 0x params for the potential transaction.
- `swapAdapter`: (string): 0x address of the swap adapter.
- `tokenOut`: (string): 0x address of the outputted token on that chain.
- `minAmountOut`: (Ethers BigNumber): The min amount of value exiting the transaction.
- `deadline`: (Ethers BigNumber): The deadline for the potential transaction.
- `rawParams`: (string): 0x params for the potential transaction.

:::

Expand All @@ -106,45 +107,45 @@ Get all relevant information regarding a possible transaction.

`bridgeQuote()` requires the following arguments:

* `fromChain` (number): Origin chain id.
* `toChain` (number): Destination chain id.
* `fromToken` (string): 0x token address on the origin chain.
* `toToken` (string): 0x token address on the destination chain.
* `amount` (Ethers BigNumber): The amount (with the correct amount of decimals specified by the token on the origin chain)
* `object` (three seperate args):
* `deadline` (Ethers BigNumber): Deadline for the transaction to be initiated on the origin chain, in seconds (optional)
* `originUserAddress` (string): Address of the user on the origin chain, optional, mandatory if a smart contract is going to initiate the bridge operation
* `excludedModules` (array): (optional) List of bridge modules to exclude from the result
- `fromChain` (number): Origin chain id.
- `toChain` (number): Destination chain id.
- `fromToken` (string): 0x token address on the origin chain.
- `toToken` (string): 0x token address on the destination chain.
- `amount` (Ethers BigNumber): The amount (with the correct amount of decimals specified by the token on the origin chain)
- An `object` with three separate args:
- `deadline` (Ethers BigNumber): Deadline for the transaction to be initiated on the origin chain, in seconds (optional)
- `originUserAddress` (string): Address of the user on the origin chain, optional, mandatory if a smart contract is going to initiate the bridge operation
- `excludedModules` (array): (optional) List of bridge modules to exclude from the result

#### Return value

`bridgeQuote` returns the following information

* `feeAmount` (Ethers BigNumber): The calculated amount of fee to be taken.
* `bridgeFee` (number): The percentage of fee to be taken.
* `maxAmountOut` (Ethers BigNumber): The maximum output amount resulting from the bridge transaction.
* `originQuery` (`Query`): The query to be executed on the origin chain.
* `destQuery` (`Query`): The query to be executed on the destination chain.
- `feeAmount` (Ethers BigNumber): The calculated amount of fee to be taken.
- `bridgeFee` (number): The percentage of fee to be taken.
- `maxAmountOut` (Ethers BigNumber): The maximum output amount resulting from the bridge transaction.
- `originQuery` (`Query`): The query to be executed on the origin chain.
- `destQuery` (`Query`): The query to be executed on the destination chain.

### `bridge()`

Use `bridgeQuote` to request a Bridge transaction

#### Parameters

* `toAddress` (number): The 0x wallet address on the destination chain.
* `routerAddress` (string): The 0x contract address on the origin chain of the bridge router contract.
* `fromChain` (number): The origin chain id.
* `toChain` (number): The destination chain id.
* `fromToken` (string): The 0x token address on the origin chain.
* `amount` (Ethers BigNumber): The amount (with the correct amount of decimals specified by the token on the origin chain)
* `originQuery` (`Query`): The query to be executed on the origin chain.
* `destQuery` (`Query`): The query to be executed on the destination chain.
- `toAddress` (number): The 0x wallet address on the destination chain.
- `routerAddress` (string): The 0x contract address on the origin chain of the bridge router contract.
- `fromChain` (number): The origin chain id.
- `toChain` (number): The destination chain id.
- `fromToken` (string): The 0x token address on the origin chain.
- `amount` (Ethers BigNumber): The amount (with the correct amount of decimals specified by the token on the origin chain)
- `originQuery` (`Query`): The query to be executed on the origin chain.
- `destQuery` (`Query`): The query to be executed on the destination chain.

#### Return value

* `to` (string): 0x wallet address on the destination chain.
* `data` (string): Output data in 0x hex format
- `to` (string): 0x wallet address on the destination chain.
- `data` (string): Output data in 0x hex format

### `allBridgeQuotes()`

Expand All @@ -165,7 +166,7 @@ const quotes = await Synapse.bridgeQuote(
43114, // Destination Chain
'0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', // Origin Token Address
'0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664', // Destination Token Address
BigNumber.from('20000000') // Amount in
BigNumber.from('20000000') // Amount in
{
// Deadline for the transaction to be initiated on the origin chain, in seconds (optional)
deadline: 1234567890,
Expand All @@ -183,37 +184,38 @@ const quotes = await Synapse.bridgeQuote(

```js
await Synapse.bridge(
'0x0AF91FA049A7e1894F480bFE5bBa20142C6c29a9', // To Address
bridgeQuote.routerAddress, // address of the contract to route the txn
42161, // Origin Chain
43114, // Destination Chain
'0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', // Origin Token Address
BigNumber.from('20000000'), // Amount
quote.originQuery, // Origin query from bridgeQuote()
quote.destQuery // Destination query from bridgeQuote()
'0x0AF91FA049A7e1894F480bFE5bBa20142C6c29a9', // To Address
bridgeQuote.routerAddress, // address of the contract to route the txn
42161, // Origin Chain
43114, // Destination Chain
'0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', // Origin Token Address
BigNumber.from('20000000'), // Amount
quote.originQuery, // Origin query from bridgeQuote()
quote.destQuery // Destination query from bridgeQuote()
)
```

## Version 0.10.0 breaking changes

### Options object

* `deadline`, `excludeCCTP` (now `excludedModules`), and `originUserAddress` parameters are now found in an (optional) options object at the end of the arguments list for `bridgeQuote()`, and `allBridgeQuotes()`.
* `excludedModules` excludes one or more modules with an array of the module names. Supported names are `SynapseBridge`, `SynapseCCTP`, and `SynapseRFQ`.
* `originUserAddress` is required as part of the options object to initiate a bridge transaction on behalf of a user.
- `deadline`, `excludeCCTP` (now `excludedModules`), and `originUserAddress` parameters are now found in an (optional) options object at the end of the arguments list for `bridgeQuote()`, and `allBridgeQuotes()`.
- `excludedModules` excludes one or more modules with an array of the module names. Supported names are `SynapseBridge`, `SynapseCCTP`, and `SynapseRFQ`.
- `originUserAddress` is required as part of the options object to initiate a bridge transaction on behalf of a user.

### Examples

```js
bridgeQuote(...arguments, {
deadline: 1234567890,
excludedModules: ["SynapseCCTP"],
originUserAddress: "0x1234...",
excludedModules: ['SynapseCCTP'],
originUserAddress: '0x1234...',
})

allBridgeQuotes({
deadline: 1234567890,
excludedModules: ["SynapseCCTP"],
originUserAddress: "0x1234...",
excludedModules: ['SynapseCCTP'],
originUserAddress: '0x1234...',
})
```

Expand Down
4 changes: 4 additions & 0 deletions docs/bridge/docs/04-Routers/RFQ/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ In a successful dispute, the relayer loses their claimable funds. This design is
## Unfulfilled requests

If a request is not fulfilled, users can reclaim their funds by using the [`claim`](https://vercel-rfq-docs.vercel.app/contracts/FastBridge.sol/contract.FastBridge.html#claim) function once the optimistic window has passed.

## Load Tester

The [`rfq-loadtest`](https://github.com/synapsecns/sanguine/tree/master/packages/rfq-loadtest) tool can be used to rapidly send ETH bridges for the purpose of load testing.
27 changes: 11 additions & 16 deletions docs/bridge/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ const config: Config = {
[
'classic',
{
gtag: {
trackingID: 'G-BBC13LQXBD',
anonymizeIP: true,
},
docs: {
sidebarPath: './sidebars.ts',
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/synapsecns/sanguine/edit/master/docs/bridge/blog-posts/',
'https://github.com/synapsecns/sanguine/edit/master/docs/bridge/',
docRootComponent: '@theme/DocRoot',
docItemComponent: '@theme/ApiItem', // derived from docusaurus-theme-openapi-docs
// docItemComponent: '@theme/ApiItem', // derived from docusaurus-theme-openapi-docs
Expand Down Expand Up @@ -90,10 +94,10 @@ const config: Config = {
},
// Replace with your project's social card
image: 'img/docusaurus-social-card.jpg',
announcementBar: {
// id: 'announcementBar-v3.2', // Increment on change
// content: `⭐️ If you like Docusaurus, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://github.com/facebook/docusaurus">GitHub</a> and follow us on <a target="_blank" rel="noopener noreferrer" href="https://twitter.com/docusaurus">Twitter ${TwitterSvg}</a>`,
},
// announcementBar: {
// id: 'announcementBar-v3.2', // Increment on change
// content: `⭐️ If you like Docusaurus, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://github.com/facebook/docusaurus">GitHub</a> and follow us on <a target="_blank" rel="noopener noreferrer" href="https://twitter.com/docusaurus">Twitter ${TwitterSvg}</a>`,
// },
navbar: {
title: 'Synapse Docs',
logo: {
Expand All @@ -107,7 +111,7 @@ const config: Config = {
position: 'left',
label: 'Docs',
},
{to: '/blog', label: 'Blog', position: 'left'},
{ to: '/blog', label: 'Blog', position: 'left' },
{
href: 'https://github.com/synapsecns/sanguine',
label: 'GitHub',
Expand All @@ -118,15 +122,6 @@ const config: Config = {
footer: {
// style: 'dark',
links: [
// {
// title: 'Docs',
// items: [
// {
// label: 'Tutorial',
// to: '/docs/intro',
// },
// ],
// },
{
title: 'Community',
items: [
Expand All @@ -149,7 +144,7 @@ const config: Config = {
items: [
{
label: 'GitHub',
href: 'https://github.com/facebook/docusaurus',
href: 'https://github.com/synapsecns/sanguine',
},
],
},
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.4.1",
"version": "0.4.4",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"nohoist": [
"**/typechain",
"**/@typechain/*",
"**/@openzeppelin/contracts-upgradeable",
"**/@openzeppelin/contracts",
"**/@openzeppelin/*",
"**/@synapsecns/solidity-devops",
"**/ds-test",
"**/forge-std"
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-rfq/.solhintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
contracts/FastBridge.sol
contracts/interfaces/IFastBridge.sol
contracts/legacy/**/*.sol
script/FastBridge.s.sol
test/FastBridge.t.sol
test/FastBridgeMock.sol
Loading

0 comments on commit 0b9d43b

Please sign in to comment.