Skip to content

Commit

Permalink
Create getInterest() method & use it for coin & router managers
Browse files Browse the repository at this point in the history
  • Loading branch information
bathord committed May 10, 2024
1 parent bbb9be0 commit bbab44d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/chains/sui.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CoinAssetData,
CoinManagerSingleton,
FlowxSingleton,
InterestProtocolSingleton,
LONG_SUI_COIN_TYPE,
RedisStorageSingleton,
RouteManager,
Expand Down Expand Up @@ -138,9 +139,22 @@ export const getAftermath = async () => {
return aftermath;
};

export const getInterest = async () => {
const { redisClient } = await getRedisClient();
const storage = RedisStorageSingleton.getInstance(redisClient);

const interest = await InterestProtocolSingleton.getInstance({
suiProviderUrl: SUI_PROVIDER_URL,
cacheOptions: { storage, ...SUI_LIQUIDITY_PROVIDERS_CACHE_OPTIONS },
lazyLoading: false,
});

return interest;
};

export const getCoinManager = async () => {
console.time(`CoinManagerSingleton.getInstance ${randomUuid}`);
const providers = await Promise.all([getAftermath(), getCetus(), getTurbos(), getFlowx()]);
const providers = await Promise.all([getAftermath(), getCetus(), getTurbos(), getFlowx(), getInterest()]);

const coinManager = CoinManagerSingleton.getInstance(providers, SUI_PROVIDER_URL);
console.timeEnd(`CoinManagerSingleton.getInstance ${randomUuid}`);
Expand All @@ -161,7 +175,7 @@ export const getWalletManager = async () => {
export const getRouteManager = async () => {
// console.time(`RouteManager.getInstance.${randomUuid}`)
const coinManager = await getCoinManager();
const providers = await Promise.all([getAftermath(), getCetus(), getTurbos(), getFlowx()]);
const providers = await Promise.all([getAftermath(), getCetus(), getTurbos(), getFlowx(), getInterest()]);

const routerManager = RouteManager.getInstance(providers, coinManager);
// console.timeEnd(`RouteManager.getInstance.${randomUuid}`)
Expand Down

0 comments on commit bbab44d

Please sign in to comment.