From 18be26fa275c26efdf4a5e77bd5f3afcf7fa005e Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 12 Dec 2024 22:17:00 +0000 Subject: [PATCH 1/7] making correct variables mandated to generate call data --- .../src/controllers/bridgeController.ts | 25 ++++++++++--------- packages/rest-api/src/routes/bridgeRoute.ts | 4 +-- .../rest-api/src/tests/bridgeRoute.test.ts | 4 ++- packages/rest-api/swagger.json | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/rest-api/src/controllers/bridgeController.ts b/packages/rest-api/src/controllers/bridgeController.ts index 44aabb5ea4..5daf5c478c 100644 --- a/packages/rest-api/src/controllers/bridgeController.ts +++ b/packages/rest-api/src/controllers/bridgeController.ts @@ -53,18 +53,19 @@ export const bridgeController = async (req, res) => { quote.originQuery.tokenOut ) - const callData = destAddress - ? await Synapse.bridge( - destAddress, - quote.routerAddress, - Number(fromChain), - Number(toChain), - fromToken, - amountInWei, - quote.originQuery, - quote.destQuery - ) - : null + const callData = + destAddress && originUserAddress + ? await Synapse.bridge( + destAddress, + quote.routerAddress, + Number(fromChain), + Number(toChain), + fromToken, + amountInWei, + quote.originQuery, + quote.destQuery + ) + : null return { ...quote, diff --git a/packages/rest-api/src/routes/bridgeRoute.ts b/packages/rest-api/src/routes/bridgeRoute.ts index 4d534306fc..f3659ab90a 100644 --- a/packages/rest-api/src/routes/bridgeRoute.ts +++ b/packages/rest-api/src/routes/bridgeRoute.ts @@ -56,13 +56,13 @@ const router: express.Router = express.Router() * required: false * schema: * type: string - * description: The address of the user on the origin chain + * description: The address of the user on the origin chain (required to generate callData) * - in: query * name: destAddress * required: false * schema: * type: string - * description: The destination address for the bridge transaction + * description: The destination address for the bridge transaction (required to generate callData) * responses: * 200: * description: Successful response diff --git a/packages/rest-api/src/tests/bridgeRoute.test.ts b/packages/rest-api/src/tests/bridgeRoute.test.ts index ce6fc247d4..2db6d090aa 100644 --- a/packages/rest-api/src/tests/bridgeRoute.test.ts +++ b/packages/rest-api/src/tests/bridgeRoute.test.ts @@ -174,7 +174,7 @@ describe('Bridge Route with Real Synapse Service', () => { expect(response.body.error).toHaveProperty('field', 'amount') }) - it('should return bridge quotes with callData when destAddress is provided', async () => { + it('should return bridge quotes with callData when originUserAddress and destAddress are provided', async () => { const response = await request(app).get('/bridge').query({ fromChain: '1', toChain: '10', @@ -182,6 +182,7 @@ describe('Bridge Route with Real Synapse Service', () => { toToken: USDC.addresses[10], amount: '1000', destAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + originUserAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', }) expect(response.status).toBe(200) @@ -200,6 +201,7 @@ describe('Bridge Route with Real Synapse Service', () => { fromToken: USDC.addresses[1], toToken: USDC.addresses[10], amount: '1000', + originUserAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', }) expect(response.status).toBe(200) diff --git a/packages/rest-api/swagger.json b/packages/rest-api/swagger.json index 2cb16577c3..01039d46c2 100644 --- a/packages/rest-api/swagger.json +++ b/packages/rest-api/swagger.json @@ -201,7 +201,7 @@ { "in": "query", "name": "destAddress", - "required": true, + "required": false, "schema": { "type": "string" }, From 171720c9eb49d2e5f2b685f86dcab173666279c6 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 12 Dec 2024 22:21:59 +0000 Subject: [PATCH 2/7] updating docs --- docs/bridge/docs/02-Bridge/02-REST-API.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/bridge/docs/02-Bridge/02-REST-API.md b/docs/bridge/docs/02-Bridge/02-REST-API.md index fc9ffbe3ce..85997870b6 100644 --- a/docs/bridge/docs/02-Bridge/02-REST-API.md +++ b/docs/bridge/docs/02-Bridge/02-REST-API.md @@ -26,7 +26,8 @@ The API is available at [`https://api.synapseprotocol.com/`](https://api.synapse | 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 | +| 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 | +| 2024‑12‑12 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/bridge) the /bridge endpoint now requires both `originUserAddress` and `destAddress` to generate call data. | ## Support From 5fe94c10aee01dc0077a667075523769a5a15ef6 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Sat, 14 Dec 2024 01:40:10 +0000 Subject: [PATCH 3/7] additional unit test --- packages/rest-api/src/tests/bridgeRoute.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/rest-api/src/tests/bridgeRoute.test.ts b/packages/rest-api/src/tests/bridgeRoute.test.ts index 2db6d090aa..39377b78c2 100644 --- a/packages/rest-api/src/tests/bridgeRoute.test.ts +++ b/packages/rest-api/src/tests/bridgeRoute.test.ts @@ -210,6 +210,22 @@ describe('Bridge Route with Real Synapse Service', () => { expect(response.body[0].callData).toBeNull() }, 15000) + it('should return bridge quotes without callData when originUserAddress is not provided', async () => { + const response = await request(app).get('/bridge').query({ + fromChain: '1', + toChain: '10', + fromToken: USDC.addresses[1], + toToken: USDC.addresses[10], + amount: '1000', + destAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + }) + + expect(response.status).toBe(200) + expect(Array.isArray(response.body)).toBe(true) + expect(response.body.length).toBeGreaterThan(0) + expect(response.body[0].callData).toBeNull() + }, 15000) + it('should return 400 for invalid destAddress', async () => { const response = await request(app).get('/bridge').query({ fromChain: '1', From 5ef5abc95319bbad20a7f70598a1c93450c14ec4 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Mon, 16 Dec 2024 19:23:45 +0000 Subject: [PATCH 4/7] updating incentivized pools --- packages/synapse-interface/constants/tokens/poolMaster.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/synapse-interface/constants/tokens/poolMaster.ts b/packages/synapse-interface/constants/tokens/poolMaster.ts index 74d797d256..c3eb59c736 100644 --- a/packages/synapse-interface/constants/tokens/poolMaster.ts +++ b/packages/synapse-interface/constants/tokens/poolMaster.ts @@ -474,7 +474,7 @@ export const CANTO_POOL_SWAP_TOKEN = new Token({ display: true, priorityRank: 6, chainId: CHAINS.CANTO.id, - incentivized: true, + incentivized: false, miniChefAddress: MINICHEF_ADDRESSES[CHAINS.CANTO.id], }) @@ -523,7 +523,7 @@ export const CANTO_WRAPPER_POOL_SWAP_TOKEN = new Token({ priorityPool: true, priorityRank: 6, chainId: CHAINS.CANTO.id, - incentivized: true, + incentivized: false, miniChefAddress: MINICHEF_ADDRESSES[CHAINS.CANTO.id], }) From 18cd32f7cd5bbfc1840c84c20fed8be4c7a6af75 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Mon, 16 Dec 2024 19:25:21 +0000 Subject: [PATCH 5/7] constants --- packages/synapse-constants/src/constants/tokens/poolMaster.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/synapse-constants/src/constants/tokens/poolMaster.ts b/packages/synapse-constants/src/constants/tokens/poolMaster.ts index d096ed5fba..212805301d 100644 --- a/packages/synapse-constants/src/constants/tokens/poolMaster.ts +++ b/packages/synapse-constants/src/constants/tokens/poolMaster.ts @@ -473,7 +473,7 @@ export const CANTO_POOL_SWAP_TOKEN = new Token({ display: true, priorityRank: 6, chainId: CHAINS.CANTO.id, - incentivized: true, + incentivized: false, miniChefAddress: MINICHEF_ADDRESSES[CHAINS.CANTO.id], }) @@ -522,7 +522,7 @@ export const CANTO_WRAPPER_POOL_SWAP_TOKEN = new Token({ priorityPool: true, priorityRank: 6, chainId: CHAINS.CANTO.id, - incentivized: true, + incentivized: false, miniChefAddress: MINICHEF_ADDRESSES[CHAINS.CANTO.id], }) From b40e44de9b3122a7346918e2310916d5afcd5bdf Mon Sep 17 00:00:00 2001 From: defi-moses Date: Mon, 16 Dec 2024 19:25:21 +0000 Subject: [PATCH 6/7] constants --- packages/synapse-constants/src/constants/tokens/poolMaster.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/synapse-constants/src/constants/tokens/poolMaster.ts b/packages/synapse-constants/src/constants/tokens/poolMaster.ts index d096ed5fba..212805301d 100644 --- a/packages/synapse-constants/src/constants/tokens/poolMaster.ts +++ b/packages/synapse-constants/src/constants/tokens/poolMaster.ts @@ -473,7 +473,7 @@ export const CANTO_POOL_SWAP_TOKEN = new Token({ display: true, priorityRank: 6, chainId: CHAINS.CANTO.id, - incentivized: true, + incentivized: false, miniChefAddress: MINICHEF_ADDRESSES[CHAINS.CANTO.id], }) @@ -522,7 +522,7 @@ export const CANTO_WRAPPER_POOL_SWAP_TOKEN = new Token({ priorityPool: true, priorityRank: 6, chainId: CHAINS.CANTO.id, - incentivized: true, + incentivized: false, miniChefAddress: MINICHEF_ADDRESSES[CHAINS.CANTO.id], }) From 7555b97f6f2b6cc52fbd1f375bd39fc76a56f632 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Mon, 16 Dec 2024 20:36:17 +0000 Subject: [PATCH 7/7] test commit --- packages/rest-api/src/routes/bridgeTxInfoRoute.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rest-api/src/routes/bridgeTxInfoRoute.ts b/packages/rest-api/src/routes/bridgeTxInfoRoute.ts index 10e74c4e50..d6bcbc7b51 100644 --- a/packages/rest-api/src/routes/bridgeTxInfoRoute.ts +++ b/packages/rest-api/src/routes/bridgeTxInfoRoute.ts @@ -20,7 +20,7 @@ const router: express.Router = express.Router() * /bridgeTxInfo: * get: * summary: "[Deprecated] in favor of using the /bridge endpoint, which now returns call data" - * description: "[Deprecated] Originally used to get Bridge transaction information" + * description: "[Deprecated] Originally used to get Bridge transaction information" test * parameters: * - in: query * name: fromChain