Skip to content

chore: isolate curve-js instances #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/main/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfiguration = {
// reactStrictMode: false, // uncomment to disable React's Strict Mode when testing page load
compiler: {
styledComponents: true
},
Expand Down
2 changes: 1 addition & 1 deletion apps/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"analyze": "ANALYZE=true next build"
},
"dependencies": {
"@curvefi/api": "2.66.30",
"@curvefi/api": "^2.66.31",
"@curvefi/llamalend-api": "^1.0.21",
"@ethersproject/abi": "^5.8.0",
"@hookform/error-message": "^2.0.1",
Expand Down
4 changes: 2 additions & 2 deletions apps/main/src/app/.well-known/walletconnect.txt/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { headers } from 'next/headers'

const WALLET_CONNECT_ACCOUNT = `c3fe8dd8-93df-44af-803f-83798aa1d440`

// for curve-dapp-git-fix-wallet-connect-curvefi.vercel.app, other domains can be added the dashboard
const VERCEL_DOMAIN_VERIFICATION = 'a88005b9d67c9ec31773975c8bd861ef2583b1c3112dbc919b809efb79b003a8'
// for curve-dapp-git-chore-curve-js-curvefi.vercel.app, other domains can be added the dashboard
const VERCEL_DOMAIN_VERIFICATION = 'bfc9255d32decb58f8e2c39e798017ff0d28a7200471a67ff1000d08e1d8a045'
// for curve.fi and staging.curve.fi
const CURVE_FI_DOMAIN_VERIFICATION = '3d76b3cd8cd754f34ac1c18ff25dc23ee9b80fc7f75800041335263b11f20b19'
// for curve.finance and staging.curve.finance
Expand Down
4 changes: 2 additions & 2 deletions apps/main/src/app/api/dex/[network]/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import cloneDeep from 'lodash/cloneDeep'
import { getAllNetworks } from '@/app/dex/[network]/pools.util'
import { refreshDataInBackground } from '@/background'
import { getPools } from '@/dex/lib/pools'
import { CurveApi, NetworkConfig, PoolDataMapper, type ValueMapperCached } from '@/dex/types/main.types'
import { createCurve } from '@curvefi/api'
import type { DexServerSideNetworkCache } from '../types'

const DexServerSideCache: Record<string, DexServerSideNetworkCache> = {}
Expand Down Expand Up @@ -39,7 +39,7 @@ const getVolumeCache = async (network: NetworkConfig, pools: PoolDataMapper) =>
* Unfortunately we cannot use an API as the pool names are generated in CurveJS
*/
const getServerSideCache = async (network: NetworkConfig) => {
const curveJS = cloneDeep((await import('@curvefi/api')).default) as CurveApi
const curveJS = createCurve() as CurveApi
await curveJS.init('NoRPC', 'NoRPC', { chainId: network.chainId })
await Promise.all([
curveJS.factory.fetchPools(),
Expand Down
4 changes: 2 additions & 2 deletions apps/main/src/dao/lib/curvejs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Eip1193Provider } from 'ethers'
import cloneDeep from 'lodash/cloneDeep'
import type { FormType as LockFormType } from '@/dao/components/PageVeCrv/types'
import { CurveApi, ChainId, Provider, EstimatedGas, UsdRatesMapper, ClaimButtonsKey } from '@/dao/types/dao.types'
import { getErrorMessage } from '@/dao/utils'
import { createCurve } from '@curvefi/api'
import type { DateValue } from '@internationalized/date'
import PromisePool from '@supercharge/promise-pool/dist'
import { log } from '@ui-kit/lib'
Expand All @@ -11,7 +11,7 @@ import { waitForTransaction, waitForTransactions } from '@ui-kit/lib/ethers'

export const helpers = {
initCurveJs: async (chainId: ChainId, provider?: Eip1193Provider) => {
const curveApi = cloneDeep((await import('@curvefi/api')).default) as CurveApi
const curveApi = createCurve() as CurveApi
if (provider) {
await curveApi.init('Web3', { network: { chainId }, externalProvider: provider }, { chainId })
} else {
Expand Down
4 changes: 2 additions & 2 deletions apps/main/src/dex/utils/utilsCurvejs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Eip1193Provider } from 'ethers'
import cloneDeep from 'lodash/cloneDeep'
import { CurveApi, ChainId, RewardsApy } from '@/dex/types/main.types'
import { createCurve } from '@curvefi/api'
import { FORMAT_OPTIONS, formatNumber } from '@ui/utils'

export async function initCurveJs(chainId: ChainId, provider?: Eip1193Provider) {
const curveApi = cloneDeep((await import('@curvefi/api')).default) as CurveApi
const curveApi = createCurve() as CurveApi
if (provider) {
await curveApi.init('Web3', { network: { chainId }, externalProvider: provider }, { chainId })
} else {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1709,15 +1709,15 @@ __metadata:
languageName: node
linkType: hard

"@curvefi/api@npm:2.66.30":
version: 2.66.30
resolution: "@curvefi/api@npm:2.66.30"
"@curvefi/api@npm:^2.66.31":
version: 2.66.31
resolution: "@curvefi/api@npm:2.66.31"
dependencies:
"@curvefi/ethcall": "npm:^6.0.13"
bignumber.js: "npm:^9.3.0"
ethers: "npm:^6.14.1"
memoizee: "npm:^0.4.17"
checksum: 10c0/bad98fb876986308b2505d13d7658352e8333628fb9de502f609f3cf41565ca5a9813a62d4eeb164fa0cf4a55f1f9d7551864da3f2bb87599ea9d22f801bc8ab
checksum: 10c0/6c47be6c82991a99420ca9c14d53be53b7d58e75a0c4f218ac74829fcde7fff257669ad4e17a2dcdae093d06c204d1e54af26ea7e00cc3eeadd68cfcff28ad8a
languageName: node
linkType: hard

Expand Down Expand Up @@ -14987,7 +14987,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "main@workspace:apps/main"
dependencies:
"@curvefi/api": "npm:2.66.30"
"@curvefi/api": "npm:^2.66.31"
"@curvefi/llamalend-api": "npm:^1.0.21"
"@ethersproject/abi": "npm:^5.8.0"
"@hookform/error-message": "npm:^2.0.1"
Expand Down