Skip to content

Commit

Permalink
Merge branch 'feat/sdk-syn-intents' into staging/syn-intents
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Jan 15, 2025
2 parents 9a08234 + 029dbe3 commit 76223f5
Show file tree
Hide file tree
Showing 28 changed files with 374 additions and 240 deletions.
Binary file added .github/workflows/assets/root-dir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions .github/workflows/solidity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Configuring a New Vercel Project for Solidity Documentation

Since we're using Vercel via github actions rather than the UI, configuring a new project requires a little extra work.

1. Click "Add New" on the home screen.
2. The project creation page will force you to import a project from github. Select any non-private repo, as this will be disconnected later.
![create project](./assets/vercel-create-project.png)me
3. Go to the settings->git and disconnect the repo.
![disconnect repo](./assets/vercel-git-page.png)
4. Get the project id from vercel.
![project id](./assets/vercel-project-id.png)
5. Set the root directory to the path in the repo where your package is located + docs
![root directory](./assets/root-dir.png)
6. [Add this variable as a secret to github actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository). As a convention this should be called `VERCEL_[PACKAGE_NAME]_DOCS_PROJECT_ID` (e.g. `VERCEL_CONTRACT_DOCS_PROJECT_ID` for contracts-core).
7. Add the project id to the PROJECT_IDS mapping in [solidity.yml](./solidity.yml) under the "Get Project ID" step.

Now you're done. Any time you push to the main branch, the Solidity documentation will be deployed to vercel.
8 changes: 8 additions & 0 deletions docs/bridge/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.6.3](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.6.2...@synapsecns/bridge-docs@0.6.3) (2025-01-13)

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





## [0.6.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/bridge-docs@0.6.1...@synapsecns/bridge-docs@0.6.2) (2024-12-16)

**Note:** Version bump only for package @synapsecns/bridge-docs
Expand Down
1 change: 1 addition & 0 deletions docs/bridge/docs/01-About/04-SYN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Liquidity for the [$SYN](https://coinmarketcap.com/currencies/synapse-2/) token
| 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) |
| Velodrome | `https://velodrome.finance/deposit?token0=0x4200000000000000000000000000000000000006&token1=0x5A5fFf6F753d7C11A56A52FE47a177a87e431655&type=-1&factory=0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a&chain=10` [](https://velodrome.finance/deposit?token0=0x4200000000000000000000000000000000000006&token1=0x5A5fFf6F753d7C11A56A52FE47a177a87e431655&type=-1&factory=0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a&chain=10) |
<br />

All $SYN token addresses can be found [here](/docs/Contracts/SYN).
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.6.2",
"version": "0.6.3",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
11 changes: 11 additions & 0 deletions packages/rest-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.8.16](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.8.15...@synapsecns/rest-api@1.8.16) (2025-01-14)


### Bug Fixes

* **rest-api:** apply default slippage ([#3489](https://github.com/synapsecns/sanguine/issues/3489)) ([f647a1c](https://github.com/synapsecns/sanguine/commit/f647a1cf8b3603ce96e5309af869a50457a6c187))





## [1.8.15](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.8.14...@synapsecns/rest-api@1.8.15) (2024-12-18)

**Note:** Version bump only for package @synapsecns/rest-api
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/rest-api",
"version": "1.8.15",
"version": "1.8.16",
"private": "true",
"engines": {
"node": ">=18.17.0"
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/src/rfq/engine/defaultEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class DefaultEngine implements SwapEngine {
// Remove extra fields before the encoding
return {
engineID: this.id,
chainId,
expectedAmountOut: amountOut,
steps: stepsOutput.map(({ token, amount, msgValue, zapData }) => ({
token,
Expand Down
65 changes: 33 additions & 32 deletions packages/sdk-router/src/rfq/engine/engineSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export enum EngineTimeout {
Long = 3000,
}

type QuoteOptions = {
allowMultiStep: boolean
timeout?: number
}

type RouteOptions = QuoteOptions & {
useZeroSlippage: boolean
}

export class EngineSet {
private engines: {
[engineID: number]: SwapEngine
Expand All @@ -49,41 +58,41 @@ export class EngineSet {
})
}

public async getQuotes(
inputs: RouteInput[],
options: { allowMultiStep: boolean; timeout?: number }
): Promise<SwapEngineQuote[]> {
// Find the quote for each input and each engine.
public async getBestQuote(
input: RouteInput,
options: QuoteOptions
): Promise<SwapEngineQuote | undefined> {
// Find the quote for each engine.
const allQuotes = await Promise.all(
inputs.map(async (input) =>
Promise.all(
Object.values(this.engines).map(async (engine) =>
this._getQuote(engine, input, options)
)
)
Object.values(this.engines).map(async (engine) =>
this._getQuote(engine, input, options)
)
)
// Select the best quote for each tokenOut.
return this._selectBestQuotes(allQuotes)
// Select the best quote.
const quote = allQuotes.reduce((best, current) =>
current.expectedAmountOut.gt(best.expectedAmountOut) ? current : best
)
return quote.expectedAmountOut.gt(Zero) ? quote : undefined
}

public async getQuote(
engineID: number,
input: RouteInput,
options: { allowMultiStep: boolean; timeout?: number }
): Promise<SwapEngineQuote> {
return this._getQuote(this._getEngine(engineID), input, options)
options: QuoteOptions
): Promise<SwapEngineQuote | undefined> {
const quote = await this._getQuote(
this._getEngine(engineID),
input,
options
)
return quote.expectedAmountOut.gt(Zero) ? quote : undefined
}

public async generateRoute(
input: RouteInput,
quote: SwapEngineQuote,
options: {
allowMultiStep: boolean
useZeroSlippage: boolean
timeout?: number
}
): Promise<SwapEngineRoute> {
options: RouteOptions
): Promise<SwapEngineRoute | undefined> {
// Use longer timeout for route generation by default.
let route = await this._getEngine(quote.engineID).generateRoute(
input,
Expand All @@ -101,7 +110,7 @@ export class EngineSet {
minFinalAmount: route.expectedAmountOut,
})
}
return route
return route.expectedAmountOut.gt(Zero) ? route : undefined
}

public getOriginQuery(
Expand Down Expand Up @@ -145,7 +154,7 @@ export class EngineSet {
private async _getQuote(
engine: SwapEngine,
input: RouteInput,
options: { allowMultiStep: boolean; timeout?: number }
options: QuoteOptions
): Promise<SwapEngineQuote> {
// Use shorter timeout for quote fetching by default.
const quote = await engine.getQuote(
Expand All @@ -154,12 +163,4 @@ export class EngineSet {
)
return options.allowMultiStep ? quote : sanitizeMultiStepQuote(quote)
}

private _selectBestQuotes(quotes: SwapEngineQuote[][]): SwapEngineQuote[] {
return quotes.map((quote) =>
quote.reduce((best, current) =>
current.expectedAmountOut.gt(best.expectedAmountOut) ? current : best
)
)
}
}
4 changes: 3 additions & 1 deletion packages/sdk-router/src/rfq/engine/kyberSwapEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type KyberSwapQuote = SwapEngineQuote & {

const EmptyKyberSwapQuote: KyberSwapQuote = {
engineID: EngineID.KyberSwap,
chainId: 0,
expectedAmountOut: Zero,
routeSummary: {
amountOut: '0',
Expand Down Expand Up @@ -112,7 +113,7 @@ export class KyberSwapEngine implements SwapEngine {
tokenIn,
tokenOut,
amountIn: amountIn.toString(),
gasInclude: false,
gasInclude: true,
onlySinglePath: input.restrictComplexity,
}
const response = await this.getQuoteResponse(
Expand All @@ -138,6 +139,7 @@ export class KyberSwapEngine implements SwapEngine {
}
return {
engineID: this.id,
chainId,
expectedAmountOut,
routeSummary: kyberSwapQuoteResponse.data.routeSummary,
}
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk-router/src/rfq/engine/noOpEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ export class NoOpEngine implements SwapEngine {
public readonly id: EngineID = EngineID.NoOp

public async getQuote(input: RouteInput): Promise<SwapEngineRoute> {
const { tokenIn, tokenOut, amountIn } = input
const { chainId, tokenIn, tokenOut, amountIn } = input
if (!isSameAddress(tokenIn, tokenOut)) {
return getEmptyRoute(this.id)
}
return {
engineID: this.id,
chainId,
expectedAmountOut: BigNumber.from(amountIn),
steps: [],
}
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-router/src/rfq/engine/odosEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type OdosQuote = SwapEngineQuote & {

const EmptyOdosQuote: OdosQuote = {
engineID: EngineID.Odos,
chainId: 0,
expectedAmountOut: Zero,
assembleRequest: {
userAddr: AddressZero,
Expand Down Expand Up @@ -136,6 +137,7 @@ export class OdosEngine implements SwapEngine {
}
return {
engineID: this.id,
chainId,
expectedAmountOut: BigNumber.from(amountOut),
assembleRequest: {
userAddr: tokenZap,
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/src/rfq/engine/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const generateAPIRoute = (

return {
engineID,
chainId: input.chainId,
expectedAmountOut: response.amountOut,
steps: [
{
Expand Down
21 changes: 12 additions & 9 deletions packages/sdk-router/src/rfq/engine/swapEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum EngineID {

export type SwapEngineQuote = {
engineID: EngineID
chainId: number
expectedAmountOut: BigNumber
steps?: StepParams[]
}
Expand Down Expand Up @@ -109,9 +110,18 @@ export const applySlippage = (
return amount.sub(amount.mul(slippage.numerator).div(slippage.denominator))
}

export const getEmptyQuote = (engineID: EngineID): SwapEngineQuote => {
return {
engineID,
chainId: 0,
expectedAmountOut: Zero,
}
}

export const getEmptyRoute = (engineID: EngineID): SwapEngineRoute => {
return {
engineID,
chainId: 0,
expectedAmountOut: Zero,
steps: [],
}
Expand All @@ -123,10 +133,7 @@ export const sanitizeMultiStepQuote = (
if (!quote.steps || quote.steps.length <= 1) {
return quote
}
return {
engineID: quote.engineID,
expectedAmountOut: Zero,
}
return getEmptyQuote(quote.engineID)
}

export const sanitizeMultiStepRoute = (
Expand All @@ -135,11 +142,7 @@ export const sanitizeMultiStepRoute = (
if (route.steps.length <= 1) {
return route
}
return {
engineID: route.engineID,
expectedAmountOut: Zero,
steps: [],
}
return getEmptyRoute(route.engineID)
}

export const getForwardTo = (recipient: Recipient): string => {
Expand Down
Loading

0 comments on commit 76223f5

Please sign in to comment.