Skip to content

Commit

Permalink
Merge 9a84556 into 7ec3fc5
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x authored Jul 16, 2024
2 parents 7ec3fc5 + 9a84556 commit 466ba94
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 11 deletions.
8 changes: 8 additions & 0 deletions packages/rest-api/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.

## [1.0.67](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-15)

**Note:** Version bump only for package @synapsecns/rest-api





## [1.0.66](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-03)

**Note:** Version bump only for package @synapsecns/rest-api
Expand Down
4 changes: 2 additions & 2 deletions 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.0.66",
"version": "1.0.67",
"private": "true",
"engines": {
"node": ">=18.17.0"
Expand All @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions packages/sdk-router/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.

# [0.8.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (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/[email protected]...@synapsecns/[email protected]) (2024-07-03)

**Note:** Version bump only for package @synapsecns/sdk-router
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-router/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/src/constants/chainIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const RFQ_SUPPORTED_CHAIN_IDS: number[] = [
SupportedChainId.BASE,
SupportedChainId.ARBITRUM,
SupportedChainId.SCROLL,
SupportedChainId.BSC,
]

/**
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/src/constants/medianTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ export const MEDIAN_TIME_RFQ = {
[SupportedChainId.ARBITRUM]: 15,
[SupportedChainId.BASE]: 15,
[SupportedChainId.SCROLL]: 15,
[SupportedChainId.BSC]: 15,
}
8 changes: 4 additions & 4 deletions packages/sdk-router/src/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions packages/synapse-interface/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.28.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-15)

**Note:** Version bump only for package @synapsecns/synapse-interface





# [0.28.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-15)


Expand Down
4 changes: 2 additions & 2 deletions packages/synapse-interface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/synapse-interface",
"version": "0.28.0",
"version": "0.28.1",
"private": true,
"engines": {
"node": ">=18.18.0"
Expand Down Expand Up @@ -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",
Expand Down
147 changes: 147 additions & 0 deletions packages/synapse-interface/pages/lifi/index.tsx
Original file line number Diff line number Diff line change
@@ -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<TokenAllowances>({})

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 (
<LandingPageWrapper>
<StandardPageContainer
connectedChainId={chain?.id}
address={address}
>
<div className="flex justify-between">
<div>
<div className="text-2xl text-white">
Revoke Li.fi Approvals (Multi-chain)
</div>
</div>
</div>
<div className="py-6">
<Grid
cols={{ xs: 1 }}
gap={6}
className="justify-center px-2 py-16 sm:px-6 md:px-8"
>
<div className="pb-3 place-self-center">
<div>
<h3>Li.fi / Jumper is investigating an ongoing exploit, and users should revoke approvals <a className="underline" target="_blank" href="https://x.com/lifiprotocol/status/1813196697641570635">- Li.fi Tweet</a></h3>
<br />
<h3>Check to see if you have any approvals at risk below:</h3>
<br />
{isConnected ? (
CHAIN_IDS.map(chainId => (
<div key={chainId}>
<h4>Chain ID: {chainId}</h4>
{Object.entries(allowances[chainId] || {}).map(([tokenName, allowance]) => (
<div key={tokenName}>
{tokenName} Allowance: {allowance.toString()}
{allowance > 0n && (
<TransactionButton
className="btn btn-primary ml-2"
pendingLabel="Revoking..."
label={`Revoke ${tokenName} Approval`}
onClick={() => handleRevoke(chainId, tokenName, TOKENS[tokenName])}
/>
)}
</div>
))}
</div>
))
) : (
<div className="flex flex-col justify-center h-full p-10">
<TransactionButton
style={{
background: 'linear-gradient(90deg, rgba(128, 0, 255, 0.2) 0%, rgba(255, 0, 191, 0.2) 100%)',
border: '1px solid #9B6DD7',
borderRadius: '4px',
}}
label="Connect wallet to check for approvals"
pendingLabel="Connecting"
onClick={() => new Promise((resolve) => {
openConnectModal()
resolve(true)
})}
/>
</div>
)}
</div>
</div>
</Grid>
</div>
</StandardPageContainer>
</LandingPageWrapper>
)
}

export default LifiPage
8 changes: 8 additions & 0 deletions packages/widget/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.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-15)

**Note:** Version bump only for package @synapsecns/widget





# [0.6.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-07-10)


Expand Down
4 changes: 2 additions & 2 deletions packages/widget/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 466ba94

Please sign in to comment.