Skip to content
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
16 changes: 12 additions & 4 deletions src/components/Portfolio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,15 @@

for (const token of tokens) {
if (token.underlyingContractId && token.poolId) {
if (
isMarketsTableExcludedMarket(
networkId as NetworkId,
token.poolId,
token.configKey
)
) {
continue;
}
const rowTokenConfigRaw = getTokenConfig(
networkId as NetworkId,
token.configKey ?? token.originalSymbol ?? token.symbol
Expand Down Expand Up @@ -2983,10 +2992,9 @@
try {
// fetch market from node api for accurate position info
// Fetch fresh market data and global data first
const markets = filterPortfolioVisibleMarketRows(
currentNetwork,
await fetchAllMarkets(currentNetwork)
);
const markets = await fetchAllMarkets(currentNetwork, {
excludeMarketsTableHidden: true,
});
// const marketDataResponse =
// await dorkfiAPIService.getAllMarketDataByNetwork(currentNetwork);
// const freshMarketData = marketDataResponse.success
Expand Down Expand Up @@ -4240,7 +4248,7 @@
marketId,
poolId,
displaySymbol: asset,
}) as any;

Check warning on line 4251 in src/components/Portfolio.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (market) {
const totalSupply = Number(market.totalDeposits ?? 0);
const maxTotalDeposits = Number(market.maxTotalDeposits ?? 0);
Expand Down Expand Up @@ -4470,7 +4478,7 @@
marketId,
poolId,
displaySymbol: asset,
}) as any;

Check warning on line 4481 in src/components/Portfolio.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (market) {
const totalBorrows = Number(market.totalBorrows ?? 0);
const maxTotalBorrows = Number(market.maxTotalBorrows ?? 0);
Expand Down Expand Up @@ -8294,7 +8302,7 @@
poolId: asset.poolId,
displaySymbol: asset.asset,
}
) as any;

Check warning on line 8305 in src/components/Portfolio.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const depositCapReached =
atRiskMarket &&
isAtDepositCap(
Expand Down Expand Up @@ -8596,7 +8604,7 @@
poolId: borrow.poolId,
displaySymbol: borrow.asset,
}
) as any;

Check warning on line 8607 in src/components/Portfolio.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const borrowCapReached =
market &&
isAtBorrowCap(
Expand Down
38 changes: 17 additions & 21 deletions src/components/SupplyBorrowCongrats.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from "react";
import { CheckCircle2, Sparkles } from "lucide-react";
import DorkFiButton from "@/components/ui/DorkFiButton";
import LpPairIconStack from "@/components/pools/LpPairIconStack";

interface SupplyBorrowCongratsProps {
transactionType: "deposit" | "borrow" | "withdraw" | "repay";
asset: string;
assetIcon: string;
/** Stacked underlying icons for Tinyman LP pair markets. */
/** Underlying pair icons for LP markets (preferred over `assetIcon` when set). */
assetPairIcons?: { asset1Icon: string; asset2Icon: string };
amount: string;
onViewTransaction: () => void;
Expand Down Expand Up @@ -54,29 +55,24 @@ const SupplyBorrowCongrats: React.FC<SupplyBorrowCongratsProps> = ({
<Sparkles className="absolute -top-3 -left-3 text-whale-gold w-7 h-7 animate-bounce" />
<Sparkles className="absolute -top-3 -right-3 text-highlight-aqua w-7 h-7 animate-bounce animation-delay-300" />
<CheckCircle2 className="w-16 h-16 text-green-500 drop-shadow-xl bg-white dark:bg-slate-800 rounded-full p-1 border-4 border-whale-gold z-10" />
{assetPairIcons ? (
<div
className="mt-[-30px] mx-auto flex -space-x-4 justify-center"
aria-hidden
>
<img
src={assetPairIcons.asset1Icon}
alt=""
className="h-24 w-24 rounded-xl border-4 border-whale-gold bg-bubble-white object-contain shadow-md dark:bg-slate-800"
<div className="mt-[-30px] mx-auto flex h-32 w-32 items-center justify-center rounded-xl border-4 border-whale-gold bg-bubble-white shadow-md dark:bg-slate-800">
{assetPairIcons ? (
<LpPairIconStack
asset1Icon={assetPairIcons.asset1Icon}
asset2Icon={assetPairIcons.asset2Icon}
fallbackIcon={assetIcon}
alt={asset}
size="md"
className="scale-[2.2]"
/>
) : (
<img
src={assetPairIcons.asset2Icon}
alt=""
className="h-24 w-24 rounded-xl border-4 border-whale-gold bg-bubble-white object-contain shadow-md dark:bg-slate-800"
src={assetIcon}
alt={`${asset} icon`}
className="h-24 w-24 rounded-lg object-contain"
/>
</div>
) : (
<img
src={assetIcon}
alt={`${asset} icon`}
className="mt-[-30px] w-32 h-32 rounded-xl shadow-md border-4 border-whale-gold mx-auto bg-bubble-white dark:bg-slate-800 object-cover"
/>
)}
)}
</div>
</div>

<h2 className="text-xl font-bold text-center mb-1">
Expand Down
5 changes: 2 additions & 3 deletions src/components/SupplyBorrowModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3201,9 +3201,7 @@ const SupplyBorrowModal = ({
};

const handleViewTransaction = () => {
if (!transactionId) {
throw new Error("Transaction ID not found");
}
if (!transactionId) return;
const net = (transactionNetworkId || network || currentNetwork) as NetworkId;
window.open(getExplorerTransactionUrl(net, transactionId), "_blank");
};
Expand Down Expand Up @@ -3290,6 +3288,7 @@ const SupplyBorrowModal = ({
onGoToPortfolio={handleGoToPortfolio}
onMakeAnother={handleMakeAnother}
onClose={onClose}
viewTransactionDisabled={!transactionId}
/>
</div>
) : (
Expand Down
5 changes: 1 addition & 4 deletions src/components/WithdrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,7 @@ const WithdrawModal = ({
}
assetIcon={tokenIcon}
assetPairIcons={tokenPairIcons}
amount={
successSnapshot?.amount ??
(amount !== "" ? amount.toString() : "")
}
amount={amount !== "" ? amount.toString() : ""}
onViewTransaction={handleViewTransaction}
onGoToPortfolio={handleGoToPortfolio}
onMakeAnother={handleMakeAnother}
Expand Down
40 changes: 39 additions & 1 deletion src/config/__tests__/lendingPoolByMarketContract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,39 @@ import {
getPoolCMarketContractIds,
getPoolCLendingPoolId,
getPoolELendingPoolId,
getPoolFLendingPoolId,
getUnitLendingCollateralContractIds,
getUnitLendingWadBorrowMarketConfig,
getUnitLendingWadBorrowMarketRef,
getUsdcLpLendingCollateralContractIds,
getUsdcLpLendingWadBorrowMarketConfig,
getUsdcLpLendingWadBorrowMarketRef,
getWadLpLendingCollateralContractIds,
getWadLpLendingWadBorrowMarketConfig,
getWadLpLendingWadBorrowMarketRef,
getWadSupplyMarketConfigsExcludingPoolCBorrow,
isPoolCMarketContract,
isUnitLpCollateralMarketContract,
isUsdcLpCollateralMarketContract,
isWadLpCollateralMarketContract,
} from "@/config";

const POOL_C = "3578814346";
const POOL_E = "3585829377";
const POOL_F = "3589083110";
const WAD_STOKEN = "3333688448";
const WAD_NTOKEN_POOL_C = "3583297246";
const WAD_NTOKEN_POOL_E = "3585972631";
const WAD_NTOKEN_POOL_F = "3589241382";
const LP_UNIT_ALGO = "3577729953";
const LP_UNIT_GOBTC = "3577777819";
const LP_WAD_UNIT = "3577783311";

describe("LENDING_POOL_BY_MARKET_CONTRACT", () => {
it("returns Pool C and Pool E ids for algorand-mainnet", () => {
it("returns Pool C, Pool E, and Pool F ids for algorand-mainnet", () => {
expect(getPoolCLendingPoolId("algorand-mainnet")).toBe(POOL_C);
expect(getPoolELendingPoolId("algorand-mainnet")).toBe(POOL_E);
expect(getPoolFLendingPoolId("algorand-mainnet")).toBe(POOL_F);
});

it("maps WAD SToken and TMPOOL2 nt200 contracts to Pool C", () => {
Expand Down Expand Up @@ -88,6 +96,36 @@ describe("LENDING_POOL_BY_MARKET_CONTRACT", () => {
).toBe(POOL_E);
}
});

it("maps Pool F USDC TMPOOL2 nt200 contracts to Pool F", () => {
for (const contractId of getUsdcLpLendingCollateralContractIds(
"algorand-mainnet"
)) {
expect(
getLendingPoolIdForMarketContract("algorand-mainnet", contractId)
).toBe(POOL_F);
expect(
isUsdcLpCollateralMarketContract("algorand-mainnet", contractId)
).toBe(true);
}
});

it("points USDC LP collateral at WAD @ Pool F (tokens.WAD row)", () => {
expect(getUsdcLpLendingWadBorrowMarketRef("algorand-mainnet")).toEqual({
poolId: POOL_F,
contractId: WAD_STOKEN,
nTokenId: WAD_NTOKEN_POOL_F,
configKey: "WAD",
});

const wadMarket = getUsdcLpLendingWadBorrowMarketConfig("algorand-mainnet");
expect(wadMarket).toMatchObject({
poolId: POOL_F,
contractId: WAD_STOKEN,
nTokenId: WAD_NTOKEN_POOL_F,
symbol: "WAD",
});
});
});

describe("UNIT lending → Pool C WAD borrow market", () => {
Expand Down
54 changes: 28 additions & 26 deletions src/config/__tests__/marketsTableExclusion.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
getMarketsTableVisibleTokensWithDisplayInfo,
getPortfolioVisibleTokens,
isMarketsTableExcludedMarket,
isMarketsTableExcludedPool,
Expand All @@ -8,14 +9,16 @@ import {

const POOL_C = "3578814346";
const POOL_E = "3585829377";
const POOL_F = "3589083110";

describe("markets table Pool C exclusion", () => {
it("excludes Pool C and Pool E at pool level", () => {
it("excludes Pool C, Pool E, and Pool F at pool level", () => {
expect(isMarketsTableExcludedPool("algorand-mainnet", POOL_C)).toBe(true);
expect(isMarketsTableExcludedPool("algorand-mainnet", POOL_E)).toBe(true);
expect(isMarketsTableExcludedPool("algorand-mainnet", POOL_F)).toBe(true);
});

it("hides Pool C and Pool E LP markets from the table", () => {
it("hides Pool C, Pool E, and Pool F LP markets from the table", () => {
expect(
isMarketsTableExcludedMarket(
"algorand-mainnet",
Expand All @@ -30,12 +33,25 @@ describe("markets table Pool C exclusion", () => {
"LP_TMPOOL2_WAD_ALGO"
)
).toBe(true);
expect(
isMarketsTableExcludedMarket(
"algorand-mainnet",
POOL_F,
"LP_TMPOOL2_USDC_ALGO"
)
).toBe(true);
});

it("keeps WAD on Pool C visible (exception)", () => {
it("keeps WAD on Pool C, Pool E, and Pool F visible (exception)", () => {
expect(
isMarketsTableExcludedMarket("algorand-mainnet", POOL_C, "WAD")
).toBe(false);
expect(
isMarketsTableExcludedMarket("algorand-mainnet", POOL_E, "WAD")
).toBe(false);
expect(
isMarketsTableExcludedMarket("algorand-mainnet", POOL_F, "WAD")
).toBe(false);
});

it("does not exclude WAD on Pool A", () => {
Expand All @@ -44,36 +60,22 @@ describe("markets table Pool C exclusion", () => {
).toBe(false);
});

it("excludes Pool C LP from portfolio visible tokens", () => {
const visible = getPortfolioVisibleTokens("algorand-mainnet");
it("omits Pool F TMPOOL2 rows from visible token list", () => {
const visible = getMarketsTableVisibleTokensWithDisplayInfo(
"algorand-mainnet"
);
expect(
visible.some(
(t) =>
String(t.poolId) === POOL_C &&
t.configKey === "LP_TMPOOL2_UNIT_ALGO"
(token) =>
token.configKey === "LP_TMPOOL2_USDC_ALGO" &&
String(token.poolId) === POOL_F
)
).toBe(false);
expect(
visible.some(
(t) => String(t.poolId) === POOL_C && t.configKey === "WAD"
(token) =>
token.configKey === "WAD" && String(token.poolId) === POOL_F
)
).toBe(true);
});

it("resolves portfolio exclusion by market contract id", () => {
expect(
isPortfolioExcludedMarketContract(
"algorand-mainnet",
POOL_C,
"3577729953"
)
).toBe(true);
expect(
isPortfolioExcludedMarketContract(
"algorand-mainnet",
POOL_C,
"3333688448"
)
).toBe(false);
});
});
Loading
Loading