Skip to content

Commit

Permalink
conditionally use backend pairs with NEXT_PUBLIC_SOROSWAP_BACKEND_ENA…
Browse files Browse the repository at this point in the history
…BLED
  • Loading branch information
abstract829 committed Jun 19, 2024
1 parent 4a3093e commit 9e944c3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/functions/generateRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const queryNetworkDict: { [x: string]: 'MAINNET' | 'TESTNET' } = {
[Networks.TESTNET]: 'TESTNET',
};

const shouldUseBackend = process.env.NEXT_PUBLIC_SOROSWAP_BACKEND_ENABLED === 'true';

export const useRouterSDK = () => {
const sorobanContext = useSorobanReact();
const { factory } = useFactory(sorobanContext);
Expand All @@ -28,16 +30,18 @@ export const useRouterSDK = () => {

const router = useMemo(() => {
return new Router({
getPairsFns: [
{
protocol: Protocols.SOROSWAP,
fn: async () => fetchAllSoroswapPairs(network),
},
{
protocol: Protocols.PHOENIX,
fn: async () => fetchAllPhoenixPairs(network),
},
],
getPairsFns: shouldUseBackend
? [
{
protocol: Protocols.SOROSWAP,
fn: async () => fetchAllSoroswapPairs(network),
},
{
protocol: Protocols.PHOENIX,
fn: async () => fetchAllPhoenixPairs(network),
},
]
: undefined,
pairsCacheInSeconds: 60,
protocols: [Protocols.SOROSWAP, Protocols.PHOENIX],
network,
Expand Down

0 comments on commit 9e944c3

Please sign in to comment.