From 5fb5e8a429511da6cd271719fcd2a43dad47d1f7 Mon Sep 17 00:00:00 2001 From: abtestingalpha <104046418+abtestingalpha@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:58:30 -0400 Subject: [PATCH 1/3] feat(sdk): Adds BSC to RFQ (#2830) * Adds BSC to RFQ * swaps out bsc for arb in test --- packages/sdk-router/src/constants/chainIds.ts | 1 + packages/sdk-router/src/constants/medianTime.ts | 1 + packages/sdk-router/src/sdk.test.ts | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/sdk-router/src/constants/chainIds.ts b/packages/sdk-router/src/constants/chainIds.ts index a72208a7e8..fcdd862176 100644 --- a/packages/sdk-router/src/constants/chainIds.ts +++ b/packages/sdk-router/src/constants/chainIds.ts @@ -61,6 +61,7 @@ export const RFQ_SUPPORTED_CHAIN_IDS: number[] = [ SupportedChainId.BASE, SupportedChainId.ARBITRUM, SupportedChainId.SCROLL, + SupportedChainId.BSC, ] /** diff --git a/packages/sdk-router/src/constants/medianTime.ts b/packages/sdk-router/src/constants/medianTime.ts index eca1509f0b..d2fcd4070c 100644 --- a/packages/sdk-router/src/constants/medianTime.ts +++ b/packages/sdk-router/src/constants/medianTime.ts @@ -51,4 +51,5 @@ export const MEDIAN_TIME_RFQ = { [SupportedChainId.ARBITRUM]: 15, [SupportedChainId.BASE]: 15, [SupportedChainId.SCROLL]: 15, + [SupportedChainId.BSC]: 15, } diff --git a/packages/sdk-router/src/sdk.test.ts b/packages/sdk-router/src/sdk.test.ts index 5edbbaed05..da26f4b5a8 100644 --- a/packages/sdk-router/src/sdk.test.ts +++ b/packages/sdk-router/src/sdk.test.ts @@ -920,8 +920,8 @@ describe('SynapseSDK', () => { describe('Errors', () => { const synapse = new SynapseSDK( - [SupportedChainId.ETH, SupportedChainId.BSC], - [ethProvider, bscProvider] + [SupportedChainId.ETH, SupportedChainId.ARBITRUM], + [ethProvider, arbProvider] ) const amount = BigNumber.from(10).pow(9) @@ -983,9 +983,9 @@ describe('SynapseSDK', () => { await expect( synapse.bridgeQuote( SupportedChainId.ETH, - SupportedChainId.BSC, + SupportedChainId.ARBITRUM, ETH_USDC, - BSC_USDC, + ARB_USDC, BigNumber.from(10).pow(3) ) ).rejects.toThrow('No route found') From 6e79b46bf980f2c6d46825fc25f0ca9e9dcd074a Mon Sep 17 00:00:00 2001 From: abtestingalpha Date: Mon, 15 Jul 2024 17:02:43 +0000 Subject: [PATCH 2/3] Publish - @synapsecns/rest-api@1.0.67 - @synapsecns/sdk-router@0.8.0 - @synapsecns/synapse-interface@0.28.1 - @synapsecns/widget@0.6.1 --- packages/rest-api/CHANGELOG.md | 8 ++++++++ packages/rest-api/package.json | 4 ++-- packages/sdk-router/CHANGELOG.md | 11 +++++++++++ packages/sdk-router/package.json | 2 +- packages/synapse-interface/CHANGELOG.md | 8 ++++++++ packages/synapse-interface/package.json | 4 ++-- packages/widget/CHANGELOG.md | 8 ++++++++ packages/widget/package.json | 4 ++-- 8 files changed, 42 insertions(+), 7 deletions(-) diff --git a/packages/rest-api/CHANGELOG.md b/packages/rest-api/CHANGELOG.md index bce56c4b86..d432db413b 100644 --- a/packages/rest-api/CHANGELOG.md +++ b/packages/rest-api/CHANGELOG.md @@ -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. +## [1.0.67](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.66...@synapsecns/rest-api@1.0.67) (2024-07-15) + +**Note:** Version bump only for package @synapsecns/rest-api + + + + + ## [1.0.66](https://github.com/synapsecns/sanguine/compare/@synapsecns/rest-api@1.0.65...@synapsecns/rest-api@1.0.66) (2024-07-03) **Note:** Version bump only for package @synapsecns/rest-api diff --git a/packages/rest-api/package.json b/packages/rest-api/package.json index 02d9f5ce2c..a90e9bfd75 100644 --- a/packages/rest-api/package.json +++ b/packages/rest-api/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/rest-api", - "version": "1.0.66", + "version": "1.0.67", "private": "true", "engines": { "node": ">=18.17.0" @@ -23,7 +23,7 @@ "@ethersproject/bignumber": "^5.7.0", "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "5.7.0", - "@synapsecns/sdk-router": "^0.7.1", + "@synapsecns/sdk-router": "^0.8.0", "bignumber": "^1.1.0", "ethers": "5.7.2", "express": "^4.18.2", diff --git a/packages/sdk-router/CHANGELOG.md b/packages/sdk-router/CHANGELOG.md index 9c8eaad2fd..0af70f6905 100644 --- a/packages/sdk-router/CHANGELOG.md +++ b/packages/sdk-router/CHANGELOG.md @@ -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. +# [0.8.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.7.1...@synapsecns/sdk-router@0.8.0) (2024-07-15) + + +### Features + +* **sdk:** Adds BSC to RFQ ([#2830](https://github.com/synapsecns/sanguine/issues/2830)) ([5fb5e8a](https://github.com/synapsecns/sanguine/commit/5fb5e8a429511da6cd271719fcd2a43dad47d1f7)) + + + + + ## [0.7.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/sdk-router@0.7.0...@synapsecns/sdk-router@0.7.1) (2024-07-03) **Note:** Version bump only for package @synapsecns/sdk-router diff --git a/packages/sdk-router/package.json b/packages/sdk-router/package.json index 26aafd310e..10de587f66 100644 --- a/packages/sdk-router/package.json +++ b/packages/sdk-router/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/sdk-router", "description": "An SDK for interacting with the Synapse Protocol", - "version": "0.7.1", + "version": "0.8.0", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/packages/synapse-interface/CHANGELOG.md b/packages/synapse-interface/CHANGELOG.md index 4d13bec4b2..7047547652 100644 --- a/packages/synapse-interface/CHANGELOG.md +++ b/packages/synapse-interface/CHANGELOG.md @@ -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.28.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.28.0...@synapsecns/synapse-interface@0.28.1) (2024-07-15) + +**Note:** Version bump only for package @synapsecns/synapse-interface + + + + + # [0.28.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/synapse-interface@0.27.3...@synapsecns/synapse-interface@0.28.0) (2024-07-15) diff --git a/packages/synapse-interface/package.json b/packages/synapse-interface/package.json index 716cb2d519..58e6f3ab0c 100644 --- a/packages/synapse-interface/package.json +++ b/packages/synapse-interface/package.json @@ -1,6 +1,6 @@ { "name": "@synapsecns/synapse-interface", - "version": "0.28.0", + "version": "0.28.1", "private": true, "engines": { "node": ">=18.18.0" @@ -34,7 +34,7 @@ "@reduxjs/toolkit": "^1.9.5", "@rtk-query/graphql-request-base-query": "^2.2.0", "@segment/analytics-next": "^1.53.0", - "@synapsecns/sdk-router": "^0.7.1", + "@synapsecns/sdk-router": "^0.8.0", "@tailwindcss/aspect-ratio": "^0.4.2", "@tailwindcss/forms": "^0.5.3", "@tailwindcss/typography": "^0.5.9", diff --git a/packages/widget/CHANGELOG.md b/packages/widget/CHANGELOG.md index 0075aa89b1..85c5805f21 100644 --- a/packages/widget/CHANGELOG.md +++ b/packages/widget/CHANGELOG.md @@ -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.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/widget@0.6.0...@synapsecns/widget@0.6.1) (2024-07-15) + +**Note:** Version bump only for package @synapsecns/widget + + + + + # [0.6.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/widget@0.5.1...@synapsecns/widget@0.6.0) (2024-07-10) diff --git a/packages/widget/package.json b/packages/widget/package.json index d7d8b969a7..3813cc5cfc 100644 --- a/packages/widget/package.json +++ b/packages/widget/package.json @@ -1,7 +1,7 @@ { "name": "@synapsecns/widget", "description": "Widget library for interacting with the Synapse Protocol", - "version": "0.6.0", + "version": "0.6.1", "license": "MIT", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", @@ -67,7 +67,7 @@ "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "^5.7.0", "@reduxjs/toolkit": "^2.0.1", - "@synapsecns/sdk-router": "^0.7.1", + "@synapsecns/sdk-router": "^0.8.0", "ethers": "^6.9.1", "lodash": "^4.17.21", "react-redux": "^9.0.2" From 9a84556c5328dc4d094e5c869eb59f1f2324260b Mon Sep 17 00:00:00 2001 From: aureliusbtc <82057759+aureliusbtc@users.noreply.github.com> Date: Tue, 16 Jul 2024 09:33:23 -0400 Subject: [PATCH 3/3] FE LiFi: Revoke approvals (#2874) * Init lifi approval revoke page * get rid of victim address and use connected address * Add some text * Only show approval data once connected * Multi-chain checker --- .../synapse-interface/pages/lifi/index.tsx | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 packages/synapse-interface/pages/lifi/index.tsx diff --git a/packages/synapse-interface/pages/lifi/index.tsx b/packages/synapse-interface/pages/lifi/index.tsx new file mode 100644 index 0000000000..954f130751 --- /dev/null +++ b/packages/synapse-interface/pages/lifi/index.tsx @@ -0,0 +1,147 @@ +import Grid from '@tw/Grid' +import { useEffect, useState } from 'react' +import { useAccount, useAccountEffect, useSwitchChain } from 'wagmi' + + +import { LandingPageWrapper } from '@layouts/LandingPageWrapper' +import StandardPageContainer from '@layouts/StandardPageContainer' +import { getErc20TokenAllowance } from '@/actions/getErc20TokenAllowance' +import { approveToken } from '@/utils/approveToken' +import { TransactionButton } from '@/components/buttons/TransactionButton' +import { useConnectModal } from '@rainbow-me/rainbowkit' + +const CHAIN_IDS = [1, 42161, 10] +const LIFI_SPENDER = "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae" + +const TOKENS = { + USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', + USDT: '0xdac17f958d2ee523a2206206994597c13d831ec7', + WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' +} as const; + +interface TokenAllowances { + [chainId: number]: { + [token: string]: bigint + } +} + +const LifiPage = () => { + const { address, isConnected, chain } = useAccount() + const { chains, switchChain: switchNetwork } = useSwitchChain() + const { openConnectModal } = useConnectModal() + + const [allowances, setAllowances] = useState({}) + + useEffect(() => { + const fetchAllowances = async () => { + if (address) { + const newAllowances: TokenAllowances = {} + + for (const chainId of CHAIN_IDS) { + newAllowances[chainId] = {} + + for (const [tokenName, tokenAddress] of Object.entries(TOKENS)) { + const allowance = await getErc20TokenAllowance({ + address, + chainId, + tokenAddress, + spender: LIFI_SPENDER, + }) + newAllowances[chainId][tokenName] = allowance + } + } + + setAllowances(newAllowances) + } + } + + if (isConnected) { + fetchAllowances() + } + }, [address, isConnected]) + + const handleRevoke = async (chainId: number, tokenName: string, tokenAddress: string) => { + if (chain?.id !== chainId) { + await switchNetwork({chainId: chainId}) + } + await approveToken(LIFI_SPENDER, chainId, tokenAddress, 0n) + setAllowances(prev => ({ + ...prev, + [chainId]: { + ...prev[chainId], + [tokenName]: 0n + } + })) + } + + return ( + + +
+
+
+ Revoke Li.fi Approvals (Multi-chain) +
+
+
+
+ +
+
+

Li.fi / Jumper is investigating an ongoing exploit, and users should revoke approvals - Li.fi Tweet

+
+

Check to see if you have any approvals at risk below:

+
+ {isConnected ? ( + CHAIN_IDS.map(chainId => ( +
+

Chain ID: {chainId}

+ {Object.entries(allowances[chainId] || {}).map(([tokenName, allowance]) => ( +
+ {tokenName} Allowance: {allowance.toString()} + {allowance > 0n && ( + handleRevoke(chainId, tokenName, TOKENS[tokenName])} + /> + )} +
+ ))} +
+ )) + ) : ( +
+ new Promise((resolve) => { + openConnectModal() + resolve(true) + })} + /> +
+ )} +
+
+
+
+
+
+ ) +} + +export default LifiPage