Skip to content

Commit

Permalink
Merge branch 'master' into synapse-interface/worldchain
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Oct 16, 2024
2 parents c28f458 + 47dc48e commit cd33ec0
Show file tree
Hide file tree
Showing 104 changed files with 3,592 additions and 712 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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
13 changes: 12 additions & 1 deletion contrib/promexporter/internal/gql/dfk/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions docs/bridge/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,60 @@
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





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


### Features

* **synapse-constants:** adds preinstall step ([#3269](https://github.com/synapsecns/sanguine/issues/3269)) ([acd61de](https://github.com/synapsecns/sanguine/commit/acd61de4846d9b23d7aa834b8f2eefcaae486c7d))





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

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





## [0.3.10](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.3.9...@synapsecns/bridge-docs@0.3.10) (2024-10-08)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
15 changes: 12 additions & 3 deletions docs/bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati
## Generating API Docs

<!--TODO: needs to be done from ci to ensure regenration is done.-->

`yarn docusaurus gen-api-docs all`.

### Installation

```
```bash
$ yarn
```

### Local Development

```
```bash
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
```bash
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Serve

This step is needed to create a searchable index.

```bash
$ yarn serve
```
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.
Loading

0 comments on commit cd33ec0

Please sign in to comment.