Skip to content

Commit

Permalink
update router-sdk and add phoenix
Browse files Browse the repository at this point in the history
  • Loading branch information
abstract829 committed Jun 19, 2024
1 parent f9832dc commit 4a3093e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"react-virtualized-auto-sizer": "^1.0.20",
"react-window": "^1.8.9",
"redux": "^4.2.1",
"soroswap-router-sdk": "1.2.6",
"soroswap-router-sdk": "^1.2.8",
"swr": "^2.2.0",
"typescript": "5.3.3",
"use-resize-observer": "^9.1.0"
Expand Down
19 changes: 12 additions & 7 deletions src/functions/generateRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useFactory } from 'hooks';
import { useContext, useMemo } from 'react';
import { CurrencyAmount, Networks, Protocols, Router, Token, TradeType } from 'soroswap-router-sdk';
import { AppContext } from 'contexts';
import { fetchAllSoroswapPairs } from 'services/pairs';
import { fetchAllPhoenixPairs, fetchAllSoroswapPairs } from 'services/pairs';

export interface GenerateRouteProps {
amountTokenAddress: string;
Expand All @@ -28,13 +28,18 @@ export const useRouterSDK = () => {

const router = useMemo(() => {
return new Router({
getPairsFn: async () => {
const data = await fetchAllSoroswapPairs(network);

return data;
},
getPairsFns: [
{
protocol: Protocols.SOROSWAP,
fn: async () => fetchAllSoroswapPairs(network),
},
{
protocol: Protocols.PHOENIX,
fn: async () => fetchAllPhoenixPairs(network),
},
],
pairsCacheInSeconds: 60,
protocols: [Protocols.SOROSWAP],
protocols: [Protocols.SOROSWAP, Protocols.PHOENIX],
network,
maxHops,
});
Expand Down
14 changes: 14 additions & 0 deletions src/services/pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@ export const fetchAllSoroswapPairs = async (networkPassphrase: string) => {
});
return data;
};

export const fetchAllPhoenixPairs = async (networkPassphrase: string) => {
const networkName = passphraseToBackendNetworkName[networkPassphrase];

const { data } = await axios.get<MercuryPair[]>(
`https://info.soroswap.finance/api/pairs/phoenix`,
{
params: {
network: networkName,
},
},
);
return data;
};
29 changes: 24 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5135,6 +5135,17 @@ glob-parent@^6.0.2:
dependencies:
is-glob "^4.0.3"

[email protected]:
version "10.3.10"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.10.tgz#0351ebb809fd187fe421ab96af83d3a70715df4b"
integrity sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==
dependencies:
foreground-child "^3.1.0"
jackspeak "^2.3.5"
minimatch "^9.0.1"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
path-scurry "^1.10.1"

glob@^10.2.2, glob@^10.3.10, glob@^10.3.12:
version "10.3.14"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.14.tgz#36501f871d373fe197fc5794588d0aa71e69ff68"
Expand Down Expand Up @@ -5764,7 +5775,7 @@ iterator.prototype@^1.1.2:
reflect.getprototypeof "^1.0.4"
set-function-name "^2.0.1"

jackspeak@^2.3.6:
jackspeak@^2.3.5, jackspeak@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8"
integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==
Expand Down Expand Up @@ -7251,6 +7262,14 @@ path-parse@^1.0.7:
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==

path-scurry@^1.10.1:
version "1.11.1"
resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2"
integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==
dependencies:
lru-cache "^10.2.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"

path-scurry@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.0.tgz#332d64e9726bf667fb348e5a1c71005c09ad741a"
Expand Down Expand Up @@ -8296,10 +8315,10 @@ [email protected]:
stellar-base v10.0.0-beta.4
urijs "^1.19.1"

[email protected].6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/soroswap-router-sdk/-/soroswap-router-sdk-1.2.6.tgz#40633e8a9d028263a80a504b325b6ec068dea5b4"
integrity sha512-i2IkVoFWlf+gxsoR1egiXWEagKC8UJj0Wj+3Z/tBZvRgvbdyoMVTv2LefB4xWrRoCC4nPiLQxcej4qPLqcrNAQ==
soroswap-router-sdk@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/soroswap-router-sdk/-/soroswap-router-sdk-1.2.8.tgz#17d5a6e69b39ce61aa6ca312f4f0f6dd28d8ec73"
integrity sha512-m8kHw5EGStNlYyE4eTBP5o5475yCNTAE+zyGUWW3uScQsLWinm7yRxq6U2biWMocMmj5Eo2rDQUmhJyrUpDanw==
dependencies:
"@stellar/stellar-sdk" "^11.3.0"
axios "^1.6.5"
Expand Down

0 comments on commit 4a3093e

Please sign in to comment.